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 > UNIX for Advanced & Expert Users
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 04-10-2008
Paul J Paul J is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 1
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
Closed Thread

Bookmarks

Tags
linux, 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 10:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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