![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Solaris 10 /proc making filesystem full | run_time_error | SUN Solaris | 18 | 06-10-2009 10:25 PM |
| Windows / Open Solaris dual boot problem. | syndex | SUN Solaris | 2 | 05-13-2008 09:10 AM |
| Making a new OS based on Solaris / OpenSolaris | Dinolinux | What's on Your Mind? | 1 | 01-24-2006 07:55 PM |
| DDD making problem | azazel11998 | High Level Programming | 0 | 03-10-2005 07:10 AM |
| Making Mozilla Playing M$ Windows Media | Dmitri-br | Linux | 2 | 02-19-2004 10:58 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Take a look at "expect" to do the uid/pw login for you: Your main script will call the expect script, which will do the actual sftp based upon the parameters you pass to it.
Expect script:- #!/usr/local/bin/expect -- # Name: to-remote-sftp-cmd # Purpose: to copy files from local directory location to a remote server # file directory location # set login [lindex $argv 0] set machine [lindex $argv 1] set password [lindex $argv 2] set remoteloc [lindex $argv 3] set target [lindex $argv 4] set timeout -1 # Perform copy spawn /usr/bin/sftp -oPort=22 $login@$machine expect "password:" send "$password\r" expect "sftp>" send "cd $remoteloc\n" expect "sftp>" send "mkdir $target\n" expect "sftp>" send "cd $target\n" expect "sftp>" send "mput *.CSV\n" expect "sftp>" send "quit\n" .. and here's the calling part:- blah, blah.. then declare the paras: remoteloc=/win_sftp_server/dest_folder target=`date +%Y%m%d` # name you want to give the new folder # V_LOG=/home/you/log/filename_$target echo $login >>$V_LOG 2>&1 # from your .netrc file echo $password >>$V_LOG 2>&1 # from your .netrc file echo $machine >>$V_LOG 2>&1 # from your .netrc file echo $remoteloc >>$V_LOG 2>&1 echo $target >>$V_LOG 2>&1 cd /files_to_transfer_folder # SFTP the CSV files to win_sftp_server: /your_script_location/scripts/clist-to-remote-sftp-cmd $login $machine $password $remoteloc $target >>$V_LOG 2>&1 exit That's it. You have to log in once manually to exchange keys, but it's automatic (cron or whatever) after that. Expect and TCL are the two s/w's you need and they're include on the SUN (Sol 10) Software Companion dvd. Regards, pj |
| Sponsored Links | ||
|
|