The UNIX and Linux Forums  

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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
connecting my server to comcast mcraul UNIX for Dummies Questions & Answers 0 04-29-2008 08:19 AM
Connecting to SUN server from PC zam UNIX for Dummies Questions & Answers 33 09-02-2007 10:04 PM
Urgent need help - issue sftp bucci SUN Solaris 1 04-05-2007 05:57 AM
Connecting to time server Hayez UNIX for Dummies Questions & Answers 5 12-02-2005 10:51 AM
Connecting to an Exchange Server camerja1 Windows & DOS: Issues & Discussions 2 08-05-2002 08:31 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-07-2008
Registered User
 

Join Date: Apr 2008
Posts: 40
Question problem with connecting sftp server(urgent please)

Hi all,

I have command to connect gateway server
iam in home directory/> ssh root@mrp-gateway
root@mrp-gateway:/root> sftp -v msgGoogle@126.132.45.123
sftp/>dir
upload --> folder
sftp/upload/ls
-------------
8990.txt
kittu.txt
8989.txt

i have an requirement to print files list which contain upload folder in the sftp server.

connectSFTP.sh
--------------------
#!/bin/bash
sftpList=`ssh root@mrp-gateway && sftp -v msgGoogle@126.132.45.123 && cd \upload\ && ls`
echo $sftpList



but this command is not working
can any one help me how to solve this issue.
Reply With Quote
Forum Sponsor
  #2  
Old 05-12-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
Your script is executing each of the commands seperated by && in order. It's not passing the additional commands to the first as it should.
As a result, your script is first ssh'ing to mrp-gateway, then once that ssh session finishes (ie it'll sit there until it gets logged out) it then attempts an sftp to 126.132.45.123 from the original server (not from the gateway).
Once that sftp session ends (or fails to connect), it will attempt to change directory (again, on the originating server) to 'upload' then run an ls on it.

I suspect what you want to do is to pass the various commands as aprameters to the earlier commands.

For example, to have the gateway server initate the sftp connection:
Code:
ssh root@mrp-gateway 'sftp -v msgGoogle@126.132.45.123'
Reply With Quote
  #3  
Old 05-12-2008
Cameron's Avatar
Registered User
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 490
Quote:
Originally Posted by Smiling Dragon View Post
Code:
ssh root@mrp-gateway 'sftp -v msgGoogle@126.132.45.123:\upload\'
Should negate the need to issue the cd statement after connecting.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0