Operating System - OpenVMS
1753767 Members
6138 Online
108799 Solutions
New Discussion юеВ

Batch mode SFTP redirecting output to a file ?

 
Thomas Ritter
Respected Contributor

Batch mode SFTP redirecting output to a file ?

Using SSH to extract a directory listing from the remote Linux SuSE server. I am not able to redirect the output streams to a file. Suspect some sub-process operation is preventing this.

Is is possible to re-direct the SSH output to a file ?
Consider
$ fname = "sftp.lis"
$ define sys$output 'fname'
$ define sys$error 'fname'
$ sftp "-B" commands.ftp server@192.68.0.1
$ deassign sys$output
$ deassign sys$error

where commands.ftp is
pwd
ls -l
quit

the file sftp.lis has the following contents
$ type sftp.lis
sftp> pwd
/
sftp> ls -l
sftp> quit
ssh_pipe_stream_destroy


This would work with FTP but not SFTP

We are running UCX 5.4 ECO 5 on VMS 7.3-2/
5 REPLIES 5
Steven Schweda
Honored Contributor

Re: Batch mode SFTP redirecting output to a file ?

I don't do sftp, hence I know nothing, but
with plain "ssh " things in a
command procedure, it was necessary to say:
-o "batchmode yes"
to get some things to work properly. I see
("sftp -h") that sftp offers an option:
"[-o option_to_ssh2]"
so it might be worth trying the "batchmode"
thing with sftp, too. No bets.
Thomas Ritter
Respected Contributor

Re: Batch mode SFTP redirecting output to a file ?

I revisit the problem for the purposes of logging a call. Surprise... today the output is correctly re-directed.
Wim Van den Wyngaert
Honored Contributor

Re: Batch mode SFTP redirecting output to a file ?

Thomas,

Did you resubmit the batch job AFTER you modified it for redirection ?
A submit command submits the last version and thus modifications done after the submit are not taken into account (until the next submit).

Wim
Wim
labadie_1
Honored Contributor

Re: Batch mode SFTP redirecting output to a file ?

Wim

you are not obliged to re-submit, you can just do
$ copy/overlay a.com; a.com;-1

It will be enough to have the lastest a.com submitted.
Thomas Ritter
Respected Contributor

Re: Batch mode SFTP redirecting output to a file ?

The input file to SFTP must be of format stream_lf. I goofed. I now have an FDL step to ensure the commands.ftp, the input to SFTP, is in the correct format. Not obvious :(