problem in making autossh between windows and solaris


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users problem in making autossh between windows and solaris
# 8  
Old 04-10-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Problem: Solaris 10 to Windows XP Connectivity

:wall: Hello Solaris Users. Although a fundamental skill I am still new to connecting computers together in order that they can see each other, ie. via ping-ing of IP's and/or hostnames. I wish to install Oracle 10g database on Sun Blade 1500 and access this from Windows XP laptop (running... (5 Replies)
Discussion started by: patcom
5 Replies

2. Solaris

installation problem solaris,windows,suse on same machine

Hi all, Previously I had both opensuse 11.3 and Windows XP SP2 on my PC, there was no problem at all.I was able to access all documents in Windows from opensuse. Now when I wanted to install solaris 10 on the same machine there were 2 problems ... 1. Windows is not accessible from solaris... (3 Replies)
Discussion started by: M.Choudhury
3 Replies

3. Solaris

Problem in File/Dir sharing between a windows and solaris

Hi , We are trying to share a particular directory between solaris running from VMware installed on Win7 box] and windows box. We tried the SWAT utility of samba, and made all possible changes for sharing. We committed the changes and we were clueless what need to be done further.. referred... (0 Replies)
Discussion started by: BalajiUthira
0 Replies

4. Shell Programming and Scripting

Problem in making itration

Hi, I have a file which keeps on appending the data continuously, i that i am looking for a particular pattern, if i dont find that pattern i want to wait for 30 seconds to check it again. can we use it like this ----------------------------- until do cat $line |... (1 Reply)
Discussion started by: Prateek007
1 Replies

5. Solaris

Windows / Open Solaris dual boot problem.

Okay, let me sketch the problem. I did have a ubuntu / Windows XP dual boot scenario that ran grub as my boot loader. I decided I wanted to try out solaris, so I popped in the opensolaris CD and hit install and told it to format and install over my linux partition. Of course it did that, and... (2 Replies)
Discussion started by: syndex
2 Replies

6. What is on Your Mind?

Making a new OS based on Solaris / OpenSolaris

Hi I'm planning on making a OS based on the Solaris kernel. And I would like to know what you think about this idea or want to contribute. I'm planning on modifying the current Solaris kernel and adding more drivers to it and making it work better on x86. This project will be completely open... (1 Reply)
Discussion started by: Dinolinux
1 Replies

7. Programming

DDD making problem

Hi Everybody, I am trying to make the ddd-3.3.9 debugger. I installed all dependencies. this is what i get: # make Making all in themes make: Entering directory `/space/atoulan/ddd-3.3.9/themes' make: Nothing to be done for `all'. make: Leaving directory... (0 Replies)
Discussion started by: azazel11998
0 Replies

8. Linux

Making Mozilla Playing M$ Windows Media

Please, Anybody knows how can i configure Mozilla Browser to play M$ Windows Media in Linux?? I know konqueror can be set to play *.ASF or *.ASX files with the kmplayer application. But Mozilla doesn't give me the option to choose an expecifc application to play this files. Is there any file in... (2 Replies)
Discussion started by: Dmitri-br
2 Replies
Login or Register to Ask a Question