Passing a password to su


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Passing a password to su
# 1  
Old 03-28-2007
Passing a password to su

Hi

I am running unix commands through Oracle, but I want to be able to run sftp which oracle cannot use. What I want to do is run a script which runs as oracle user but has the su command in, to connect as another user that has sftp access. I am trying the below.

su - dwintuser -c gary.ksh <<EOF
`echo $passwd`
EOF

This does not work as I can't seem to be able to pass a password to su. Is there a way round this or another option for running sftp as an oracle user without the oracle user having access to the ftp server.

Cheers
Gary
# 2  
Old 03-28-2007
using Expect might help you
# 3  
Old 03-29-2007
Something like :

Code:
spawn sftp -o Port=$port $user@$host
expect assword:

send "$pass\r"
expect sftp>

send "$cmd $from_file $to_file\r"
expect sftp>

send "exit\r"
expect eof

where you should replace all the respective variables.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing password with SSH command

Hi Experts, I have specific requirement where I want to pass the password with the ssh username@hostname command . I dont want to use RSA public and private keys also. Because that will be on production server and no one wants to give access like that. Second thing it is production... (14 Replies)
Discussion started by: sharsour
14 Replies

2. UNIX for Dummies Questions & Answers

Passing password to sudo login

Hi All, I am trying use the below su command to execute a shell script using different user. Caould some one please help me out as to how to pass the pass the password when prompted or is there any way to execute the shell script using other user. I have had look at the other posts in forum... (1 Reply)
Discussion started by: abhi_n123
1 Replies

3. Shell Programming and Scripting

Passing password for ssh in Script

I want to do following 2 commands via script: 1) eval `ssh-agent`2) ssh-add /export/home/sufuser/.ssh/id_rsa When asked for passphrase enter "passwordpassword1234 but whenever I run the script it stucks after "ssh-add /export/home/sufuser/.ssh/id_rsa" command and asks fro... (4 Replies)
Discussion started by: yogeshpawar
4 Replies

4. UNIX and Linux Applications

SFTP without passing the password

Hi All, I am trying to do SFTP without passing the password. I did it by generating the Key pair on both source and destination servers but the problem is My script is running with BATCHADM user whereas I am doing SFTP using another username (sftp user1@destinationServer) due to which it is... (3 Replies)
Discussion started by: kaurr06
3 Replies

5. Shell Programming and Scripting

passing password to a command

Hi all, I have the expect binaries in our boxes.. I want to pass a passwd to a command automatically without manual intervention using "/<path_of_expect>/expect/<version>/bin/autopasswd" The below command will ask passwd in my script cleartool rmtag -all <vob_tag> #Some... (4 Replies)
Discussion started by: raghu.iv85
4 Replies

6. Shell Programming and Scripting

Passing Password into scp Command

Hi Everyone, I'm trying to run scp as a one-line command, as of right now, it prompts me for the user's password to the remote machine. Does anyone know if there is an option to pass the password parameter into the scp command on the same line so it doesn't prompt me? Thanks! (1 Reply)
Discussion started by: twhitmarsh
1 Replies

7. Shell Programming and Scripting

SSH Login by passing password.

ssh/sftp login by passing password , is it possible.Don't want to expect. (1 Reply)
Discussion started by: dinjo_jo
1 Replies

8. Shell Programming and Scripting

passing password in shell script

Hi, Anybody help to write a shell script as below requirement. script stops some costomized application services. 1. first it will stop apache as root 2. then it will switch to my application user and stop app service. Note: passing password is required to stop app service as app... (1 Reply)
Discussion started by: manojbarot1
1 Replies

9. Shell Programming and Scripting

Passing the password in csh ( su )

Hi, How do I pass the password from a csh script when I su to a different user ? ( Root is not running this script ) Thanks (1 Reply)
Discussion started by: ayeger
1 Replies

10. Shell Programming and Scripting

passing password to rlogin

I have access to seperate Unix server that has specific scripts that I need to run from time to time. What I would like to do is pass my password in the script, instead of having to type the password then run the script all from the original script. Is this possible? ;) (2 Replies)
Discussion started by: jagannatha
2 Replies
Login or Register to Ask a Question