Hello
I am trying su from one user to another in a script. Now the person who runs the script(user) cannot have the password for the user he is su -ing to (webuser) .
Here is my script which performs su . This is a hack job based on a few hours of web search.
as you can see the script has to run by passing the webuser password as a parameter as such:
I would be passing the password using plink in an exe file.
All this works fine, I was wondering if there is a way to write the entire script I wrote in a single command format so that I can use it in the plink statement itself thus eliminating the need for ./expectscript.sh which basically calls another script testwebuser.sh?
if testwebuser is performing just a few tasks, would it be possible to eliminate both scripts and directly su to a differnt user and execute commands ( any other language/tool/ solution are also welcome)
the sudo utility is really the way to go here. Assume you want to start two background tasks "/usr/local/bin/service1 -start -b" and "/bin/service2 -Y" as user webadmin you could do it like this:
sudo has a configuration file (/etc/sudoers) where you would can allow testwebuser (or anyone in testgrp group for example) to run these two commands (and only these two) as user webadmin without prompting for a password:
My initial reaction was sudo as well. However the servers are managed by another datacenter and it is not possible for me to get them to add a sudo command for every time I think up a script.
The idea here is that other users performing testing in this environment can run certain scripts that I provide to them ( say a script to run jra recordings or restart a weblogic server) without knowing what they are running. I would keep providing them new scripts based on their requests. I do not have root access either, I only have access to webuser, while they log in as user.
Hence I need a flexible solution , which does not involve the datacenter getting involved.
Sudo is pretty flexable, you could get the datacenter to setup an cmd_Alias pointing to a certain directory (that you control) and allow any scripts in that directory to be run by "user" as "webuser"
If you have to provide a new script just put it in your ~/asme directory and away you go, just make sure you have tight restrictions on access to this directory and it's all pretty safe.
Thanks Chubler, will definitely give this a try. It was one of the things I was trying to look into, but couldnt figure out how to do it.
I will update the post, once I try it out
Hi All,
I need help in making my script run perfectly as expected.
This is a snippet from my script. I am trying to read the ";" from the below output using the expect command, but the command is not detecting it. Could you please help me correct the expect string?
Snippet:
----
---... (2 Replies)
I have a tar file that contains multiple .Z files. Hence I need to issue a tar command followed by a gzip command to fully extract the files. How do I do it in a single command?
What I'm doing now is
tar xvf a.tar (this will output 1.Z and 2.Z)
gzip -d *.Z (to extract 1.Z and 2.Z) (9 Replies)
Hi, I wanted to automate the scp command where i do not want to enter the password each time. So thought of using expect command. Script is executing without any issues but files are not copied to remote server. Can any one help me?
Below is my shell script..
#!/bin/ksh
... (1 Reply)
Hi,
I am using following commands in my script to send a password to scp command. Everything is working fine except that I need a return code from the scp command. Do any one have an idea how to receive the exit code of scp command from expect.
/usr/bin/expect << EOF
spawn -noecho scp -pq... (0 Replies)
Hi,
10.152.165.217 and 10.152.165.218 are two servers that i use. I would like to access 218 from 217 using expect command. i'm not aware of how to use the command. Could anyone help me with it with a script snippet
-> imagine abc be the user in 217 with passwd abc123
-> imagine xyz be... (1 Reply)
Hello,
I am doing a project which asks me to enter password 4 times in a row. I need to enter the same password 4 times. My target is to enter password once and apply it 4 times.
My friend told me to use "expect" command. Can you please give me a sample code to do so.
sample command :- $ ssh... (1 Reply)
Dear Unix Guru,
I have several directories as below
/home/user/
dir1
dir2
dir3
Each directory has different size. I want to print each directory size (Solaris command du -hs .)
Can you please guide me how to achieve this?
Thanks
Bala (2 Replies)
Hello,
I have problem in writing the shell script involving MPE command STREAM related to HP-UX and Unix command. Script is
sh "nlshCMD 'STREAM <job name1>' | 'SHOWJOB' | grep $HPJOBNUM"
sh "nlshCMD 'STREAM <job name2>' | 'SHOWJOB' | grep $HPJOBNUM"
sh "nlshCMD 'STREAM <job name3>' |... (1 Reply)
Hello,
I have problem in writing the shell script involving MPE command STREAM related to HP-UX and Unix command. Script is
sh "nlshCMD 'STREAM <job name1>' | 'SHOWJOB' | grep $HPJOBNUM"
sh "nlshCMD 'STREAM <job name2>' | 'SHOWJOB' | grep $HPJOBNUM"
sh "nlshCMD 'STREAM <job name3>' |... (0 Replies)
I need to run a remote application(GUI) in a client.i.e on running a script in the client machine i should get the GUI application which is running in the server by providing password through the script.Will expect or autoexpect command suit for this scenario?
could anyone help me by posting some... (0 Replies)