The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script(s) to Automate Tasks droppedonjapan Shell Programming and Scripting 2 05-21-2008 10:32 AM
script to automate mksysb via nim in AIX 5.3 barkath Shell Programming and Scripting 0 12-20-2007 06:46 PM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 10:15 AM
Automate batchfile generation for sFTP mpang_ Shell Programming and Scripting 0 04-26-2006 05:34 AM
automate the input in a script erwinspeybroeck UNIX for Dummies Questions & Answers 11 01-31-2002 10:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-25-2007
tungaw2004 tungaw2004 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 31
Hi,

I did the same as you did. but what is the reason why i can't make it work? btw, this is my script.
------
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}

set timeout -1
spawn /usr/bin/sftp user1@server1
match_max 100000
expect -exact "Connecting to server1...\r
user1@server1's password: "
send -- "hardcode_password\r"
expect -exact "\r
sftp> "
send -- "cd .ssh\r"
expect -exact "cd .ssh\r
sftp> "
send -- "get file1\r"
expect -exact "get file1\r
Fetching /users/user1/.ssh/file1 to file1\r
sftp> "
send -- "exit\r"
expect eof

i think the only difference we had is how the password file was handled. what is the $authfile in your script?

thanks
  #2 (permalink)  
Old 05-04-2007
pondlife pondlife is offline
Registered User
  
 

Join Date: May 2004
Location: UK
Posts: 85
Unattended SFTP

Hi All,

I'm attempting the same thing here; my particular problem is that I'm trying to get files from a UNIX box to a VMS box with different account names. So, I believe, the shared public key option wouldn't work for me (because the account names have to be the same?).

Anyway, I'm interested in the 'expect' solutions posted by the previous participants of this thread but they don't seem to work for me. In the last post there's a variable $arg mentioned - is this the password? And is this passed on the command line?

Many thanks,

p.
  #3 (permalink)  
Old 10-12-2007
mab623 mab623 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 4
Hello All,

I figured Id save people a whole bunch of problems with this process. When you automate SFTP using expect the "-b" flag WILLNOT work under crontab due to differences in the enviroment. You must wrap all the sftp commands that you want to use inside the expect script and axe the batch script. If you tell it to run off of a batch script it will work running manually however not through cron.
  #4 (permalink)  
Old 03-20-2008
konark konark is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 14
sftp to windows

I read the artcile and observed that this is between a local unix to another local unix machine. What is the procedure if the remote server is windows????
  #5 (permalink)  
Old 03-26-2008
pbrowne pbrowne is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
I too am attempting to write a shell script using expect to automate a file transfer from a Windows box to a Sun box.

I have eliminated the -B option and have hard coded all prompts and replies in my expect script and it actually runs via cron however I am only getting a partial download.

Here is the expect script:

#!/usr/local/bin/expect -f -d
spawn sftp -v ftplogin@ftpserver
expect "ftplogin@ftpserver's password: "
sleep 7
send "thepassword\r";
expect "sftp>"
send "lcd /tmp\r"
expect "sftp>"
send "get dailyinventory.txt\r"
expect "sftp>"
send "exit\r"

Here is a sample of the log created by the -v option

spawn sftp -v ftpuser@ftpserver
Connecting to ftpserver...
Sun_SSH_1.1, SSH protocols 1.5/2.0, OpenSSL 0x0090700f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: ssh_connect: needpriv 0
debug1: Connecting to ftpserver [ftpserver] port 22.
debug1: Connection established.
debug1: identity file /.ssh/id_rsa type -1
debug1: identity file /.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version WRQReflectionForSecureIT_6.1 Build 21
debug1: no match: WRQReflectionForSecureIT_6.1 Build 21
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-Sun_SSH_1.1
debug1: Failed to acquire GSS-API credentials for any mechanisms (No credentials were supplied, or the credentials were unavailable or inaccessible
mech_dh: Invalid or unknown error
)
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: Peer sent proposed langtags, ctos:
debug1: Peer sent proposed langtags, stoc:
debug1: We proposed langtags, ctos: i-default
debug1: We proposed langtags, stoc: i-default
debug1: dh_gen_key: priv key bits set: 131/256
debug1: bits set: 495/1024
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'ftpserver' is known and matches the DSA host key.
debug1: Found key in /.ssh/known_hosts:5
debug1: bits set: 528/1024
debug1: ssh_dss_verify: signature correct
debug1: newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: done: ssh_kex2.
debug1: send SSH2_MSG_SERVICE_REQUEST
debug1: got SSH2_MSG_SERVICE_ACCEPT
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying public key: /.ssh/id_dsa
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
ftpuser@ftpserver's password:
debug1: Authentication succeeded (password)
debug1: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug1: send channel open 0
debug1: Entering interactive session.
debug1: ssh_session2_setup: id 0
debug1: Sending subsystem: sftp
debug1: channel request 0: subsystem
debug1: channel 0: open confirm rwindow 100000 rmax 32768
sftp> lcd /tmp
sftp> get dailyinventory.txt
Fetching /HOME/dailyinventory.txt to dailyinventory.txt


The problem is that the dailyinventory.txt file download has 16,586 records but the dailyinventory.txt file on the ftpserver has 68,082 records.

Wondering if anyone else has seen this problem w/ partial downloads?

Thanks in advance,

pat
  #6 (permalink)  
Old 04-17-2008
barbarica barbarica is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 1
Quote:
Originally Posted by konark View Post
I read the artcile and observed that this is between a local unix to another local unix machine. What is the procedure if the remote server is windows????
you can mount the win FS using SAMBA and working like it has unix
  #7 (permalink)  
Old 07-31-2008
meganya meganya is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 1
Hi,
I need to write a script which PULLs files from UNIX server (Solaris) to another UNIX box (Solaris). My requirements are as follows:
(1) I dont want to generate key pairs coz I would be having atleast 50 remote servers from which I need to PULL files
(2) No clear-text user/name passwords
(3) I was looking for NET::SFTP using perl scripting but there are some issues installing the NET::SFTP module currently

Can anyone help me out here with some other option to PULL files securely?

Thanks!
Closed Thread

Bookmarks

Tags
linux, linux commands, mtime, sftp script, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0