Need help in automation


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Need help in automation
# 1  
Old 04-03-2012
Need help in automation

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..

Code:
#!/bin/ksh

TMP_FILE="/tmp/testestest"
/usr/bin/expect -d <<EOD
spawn /usr/bin/scp $TMP_FILE user2@123.123.123.123:/tmp/backup/logs/
expect "password:"  { send "user1234\r" }
EOD

Output:

Code:
expect version 5.42.1
argv[0] = /usr/bin/expect  argv[1] = -d
set argc 0
set argv0 "/usr/bin/expect"
set argv ""
executing commands from command file
spawn /usr/bin/scp /tmp/testestest user2@123.123.123.123:/tmp/backup/logs/
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {31719550}

expect: does "" (spawn_id exp4) match glob pattern "password:"? no
********************************************************************************
* This system was LDAP clientized on Wed Aug  3 14:49:58 CUT 2011              *
********************************************************************************

expect: does "********************************************************************************\r\n* This system was LDAP clientized on Wed Aug  3 14:49:58 CUT 2011              *\r\n********************************************************************************\r\n" (spawn_id exp4) match glob pattern "password:"? no
user2@123.123.123.123's password:
expect: does "********************************************************************************\r\n* This system was LDAP clientized on Wed Aug  3 14:49:58 CUT 2011              *\r\n********************************************************************************\r\nwsadmin@159.202.157.176's password: " (spawn_id exp4) match glob pattern "password:"? yes
expect: set expect_out(0,string) "password:"
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "********************************************************************************\r\n* This system was LDAP clientized on Wed Aug  3 14:49:58 CUT 2011              *\r\n********************************************************************************\r\nwsadmin@159.202.157.176's password:"
send: sending "user1234\r" to { exp4 }


Last edited by balasubramani04; 04-03-2012 at 01:59 PM.. Reason: code tags not useful without newlines.
# 2  
Old 04-03-2012
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)



Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
# 3  
Old 04-03-2012
The proper way to automate SFTP is using keys. There are tutorials for 'passwordless ssh' all over the internet, which apply equally well to sftp, because they are in fact the same protocol.

It's very simple. Generating the right files and putting them in the right places will allow you to connect without a password without kludging it with a third-party brute-forcing utility.

This is also the preferred way to do it because it does not require you to store passwords. It is nearly impossible to keep reversibly-stored passwords safe.
# 4  
Old 04-03-2012
Network

I have tried to steps mentioned in Password less SSH. But for me still asking for password..

Steps Performed

Code:
1. ssh-keygen -t rsa
given empty passpharse
2. created dir in remote server
3. appended the public key into authorized_keys
4. tried to ssh but it is asking for password:mad:

Can anyone help me
# 5  
Old 04-03-2012
Have you set the permissions of the .ssh directory and its files? The .ssh directory should be set to 0700 for example and authorized_keys should have 0600

Last edited by Scrutinizer; 04-03-2012 at 04:07 PM..
# 6  
Old 04-03-2012
hi Scrutinizer,

thanks for info. but I already tried with permission as indicated by you. but it is not working...
# 7  
Old 04-03-2012
Tell us more about your systems.

Show us the permissions you have with

Code:
ls -ld ~/.ssh ; ls -l ~/.ssh

...on both the local and remote sides.

Try
Code:
ssh -v -v username@host

to see if it prints any more information.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script Automation

Hi Gurus, I have a clearcase script that i use to check in a single file at time on my clearcase server. the script is as follows setmyview settask 75098_MSI_TRILOGY_EIM cd /vobs/Trilogy_R12/custom/msieim/12.0.0/sql/ cleartool co -nc . ct mkelem -nc Filename_1.sql cp... (3 Replies)
Discussion started by: r_t_1601
3 Replies

2. Shell Programming and Scripting

automation using python

Im trying to write an automation script using python. I expect this script to log in to a remote server, execute commands and get its output. import pexpect child=pexpect.spawn('ssh myuser@192.168.151.80') child.expect('Password:') child.sendline('mypassword') get_output =... (4 Replies)
Discussion started by: Arun_Linux
4 Replies

3. Shell Programming and Scripting

scp automation

hi there , i want to use the scp to transfer the file from one machine to another machine non-stop. i have put it in a .sh file. but everytime i run it and it prompts me to input password. pc3@pc3-desktop:~/Documents$ ./sample3.sh pc-main@192.168.1.117's password: screenshot.jpg ... (4 Replies)
Discussion started by: Ericyue
4 Replies

4. Shell Programming and Scripting

Automation of UI using shellscript

Hi, I want to do automation on UI using shellscript. eg: 1) Drop down menu contains assign , investigate, closed. now there is one id want assign it using assign tab then need to investigate it and lastly close. Sometimes the id can't assign to perticular user. there are so many... (11 Replies)
Discussion started by: aish11
11 Replies

5. Shell Programming and Scripting

Tar automation

Hi, i'm new in shell programming, i would like to archive automatically all my log files at the end of each month. My files have this format : 2011.07.log1 2011.07.log2 ... 2011.08.log1 2011.08.log2 ... etc I would like to have an idea about how to do this. Thanks. (2 Replies)
Discussion started by: thedriver
2 Replies

6. UNIX for Dummies Questions & Answers

password automation

i am doing automation of report in unix. i am copying files from different server using scp command.. if i use scp its asking for password for copying files..is there any way to automate this password issue.. can anyone help me out??? tahnks in advance, Arun Manas (4 Replies)
Discussion started by: arunmanas
4 Replies

7. Shell Programming and Scripting

Scripting for automation

Hi, I would like to know about a automated script which would collect data on a regular day to day basis at a particular time and stores it in a defined path for business analysis. Any help on this is highly appreciable!! Thanks Sara (6 Replies)
Discussion started by: sara23
6 Replies

8. Shell Programming and Scripting

UNIX automation

Hello People, I have an outstanding issue with me I have 5 files at location /usr/abc called 1.DE 1.TXT 2.DE 2.TXT 3.DE 3.TXT 4.DE 4.TXT 5.Fe.ok My work involves few manual process like transfer 1.DE 1.TXT and 5.Fe.ok to /usr/dob location and run one script(for example -... (42 Replies)
Discussion started by: j_panky
42 Replies

9. Shell Programming and Scripting

Help need for automation of su command

Hi All! I need to automate the su command using expect script.Suppose I login as a user A , I need to change the user to oracle using the su oracle command and execute the command "sqlplus -ver". I tried writing a expect script for the same , but can't figure out the reason it is not working. ... (1 Reply)
Discussion started by: nua7
1 Replies

10. Shell Programming and Scripting

Help in automation...

Hi All, I need to run the same command on many servers. I am using ssh for the same. Following is the script that I am using to fire the same command on multiple machines. #!/bin/bash # Linux/UNIX box with ssh key based login #SERVERS="iqmevrick,iqmango" # SSH User name USR="root" #... (1 Reply)
Discussion started by: nua7
1 Replies
Login or Register to Ask a Question