![]() |
|
|
|
|
|||||||
| 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 |
| Redirect output | mpang_ | Shell Programming and Scripting | 1 | 08-15-2007 05:57 AM |
| Redirect output to a file | jimmyc | UNIX for Dummies Questions & Answers | 11 | 01-31-2007 08:34 AM |
| redirect output to file | xadamz23 | Shell Programming and Scripting | 4 | 06-29-2006 08:20 AM |
| redirect output of FTP | kcaluwae | Shell Programming and Scripting | 4 | 06-23-2005 05:45 AM |
| redirect output to file? | slackware | Shell Programming and Scripting | 1 | 09-11-2003 11:57 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Redirect output from sFTP
Hey all,
I have a ksh script which used ftp to transfter certain files to a AIX server, however, now I have to switch to sFTP and I have the following problem. Originally, output=`ftp -nv $AIX_HOST << EOF 2>&1 user $AIX_USER $AIX_PASSWORD cd /hsbc/risdev/risdevhfi/app/ftp/incoming put "$filename" quit EOF` Now, I am using sFTP I don't know if I can do something like this output=sftp -B $BATCHFILE $AIX_USER@$AIX_HOST If not, what am I suppose to do to get the output from the sFTP? thanks! Later, Pang |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Read the sftp man page - the -B option is for buffer, not batch. You would need the lowercase -b option for the batchfile.
|
|
#3
|
|||
|
|||
|
Hi
Try this sftp $SFTP_USER@$SFTP_HOST yes <<-! lcd $DATA_DIR cd $SFTP_REMOTE_DIR put $REPORT quit ! Remember for Sftp we cant suppply password as part of acript.So you need to generate a passowrd less key and get the public key and put that public key in $HOME/.ssh/known_hosts file or similar file under .ssh directory in your home directory. The passwordless key can be genarted using ssh-key gen program. Hope this helps. |
|
#4
|
|||
|
|||
|
reddymails, would you please explain what this "<<-!" means?
I am new with scripting so I know very little and if you don't mind me asking what is the difference between "<<" and "<", I see people use them quite often. Thanks! |
|
#5
|
||||
|
||||
|
mpang_, the <<-! that reddymails has used is exactly the same as the <<EOF that was in use in your script before.
The use of the '<<' operator is explained in the man page of ksh: Quote:
|
|
#6
|
|||
|
|||
|
So...does it mean
sftp $SFTP_USER@$SFTP_HOST yes <<-! 2>&1 will provide the output that I need? "<<-!" or "<<EOF" read the output until end of file and then ">" redirect that output to where I want? thanks guys! |
|
#7
|
||||
|
||||
|
You've almost got it. Just that in your statement
Quote:
Also, the 'read the output till end of file' should be 'read the input till the end of file'. |
||||
| Google The UNIX and Linux Forums |