![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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' |
|
#3
|
||||
|
||||
|
Should negate the need to issue the cd statement after connecting.
|
||||
| Google The UNIX and Linux Forums |