<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Catching the SFTP output in a file in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117789#M13781</link>
    <description>Hi Dan,&lt;BR /&gt;see the John Gillings' solution above (Dec 18, 2007). It's tricky, but it works perfectly!</description>
    <pubDate>Mon, 16 Mar 2009 06:41:07 GMT</pubDate>
    <dc:creator>john nicoara</dc:creator>
    <dc:date>2009-03-16T06:41:07Z</dc:date>
    <item>
      <title>Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117779#M13771</link>
      <description>Does someone have experience with the re-direction of the SFTP output to a file? I'm burden with the SFTP extricancies using eg. sys$output for 'ls' (list dir) but sys$error for 'get'! Re-directing both sys$output and sys$error to the same file ones get different versions of the same filename!&lt;BR /&gt;&lt;BR /&gt;john</description>
      <pubDate>Mon, 17 Dec 2007 17:06:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117779#M13771</guid>
      <dc:creator>john nicoara</dc:creator>
      <dc:date>2007-12-17T17:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117780#M13772</link>
      <description>What is your intended use for the output?</description>
      <pubDate>Mon, 17 Dec 2007 19:52:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117780#M13772</guid>
      <dc:creator>Richard Whalen</dc:creator>
      <dc:date>2007-12-17T19:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117781#M13773</link>
      <description>john,&lt;BR /&gt;&lt;BR /&gt;  I've found capturing output and status from SSH and SFTP is a bit tricky. They seem to have some kind of assumption about the output device, based on what they see as SYS$COMMAND. Hence the message you will sometimes see as the first output.&lt;BR /&gt;&lt;BR /&gt;"Warning: Need basic cursor movement capability, using vt100"&lt;BR /&gt;&lt;BR /&gt;  Redirecting SYS$COMMAND to NL: seems to help.&lt;BR /&gt;&lt;BR /&gt;  Here's a possible solution using the PIPE command.&lt;BR /&gt;&lt;BR /&gt;$ PIPE (DEFINE/USER SYS$COMMAND NL: ; -&lt;BR /&gt;  SFTP "-B" commands "user@node"  ; -&lt;BR /&gt; DEFINE/JOB/NOLOG SFTP_STAT &amp;amp;$STATUS) | -&lt;BR /&gt; COPY SYS$PIPE: SFTP.OUT&lt;BR /&gt;&lt;BR /&gt;At completion, the job logical name SFTP_STAT will contain the completion status of the SFTP command, and SFTP.OUT will contain all the output from the command. I tested this with "ls" and "get" commands. The output from both was written to a single version of SFTP.OUT&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Dec 2007 21:57:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117781#M13773</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2007-12-17T21:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117782#M13774</link>
      <description>forgot to mention...&lt;BR /&gt;&lt;BR /&gt;depending on what you want to do with your output, you might not need to write it to a file at all. You can obviously replace the COPY command in that pipeline with SEARCH or any other command, program or procedure you want.</description>
      <pubDate>Mon, 17 Dec 2007 22:05:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117782#M13774</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2007-12-17T22:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117783#M13775</link>
      <description>&lt;!--!*#--&gt;From a working example ...&lt;BR /&gt;$ fname = "sftp.lis" &lt;BR /&gt;$ open/write out sftp_dir.tmp&lt;BR /&gt;$ write out "cd ''csa_output_directory'"&lt;BR /&gt;$ write out "ls -l"&lt;BR /&gt;$ write out "quit"&lt;BR /&gt;$ close out&lt;BR /&gt;$ convert/fdl=sys$input: sftp_dir.tmp sftp_dir.cmd&lt;BR /&gt;                        RECORD; FORMAT STREAM_LF&lt;BR /&gt;$ delete sftp_dir.tmp;&lt;BR /&gt;$ type sftp_dir.cmd &lt;BR /&gt;$! &lt;BR /&gt;$MAIN:&lt;BR /&gt;$&lt;BR /&gt;$ define sys$output 'fname'&lt;BR /&gt;$ sftp "-B" sftp_dir.cmd  -o "quietmode yes" secret@192.168.0.1&lt;BR /&gt;$ deassign sys$output&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Dec 2007 23:17:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117783#M13775</guid>
      <dc:creator>Thomas Ritter</dc:creator>
      <dc:date>2007-12-17T23:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117784#M13776</link>
      <description>Thomas,&lt;BR /&gt;&lt;BR /&gt;  small improvement... Rather than create a file then CONVERT it, you can create it with the correct record format, like this&lt;BR /&gt;&lt;BR /&gt;$ CREATE/FDL=sys$input: sftp_dir.cmd&lt;BR /&gt;RECORD; FORMAT STREAM_LF&lt;BR /&gt;$ OPEN/APPEND out sftp_dir.cmd&lt;BR /&gt;$ write out "cd ''csa_output_directory'"&lt;BR /&gt;$ write out "ls -l"&lt;BR /&gt;$ write out "quit"&lt;BR /&gt;$ close out&lt;BR /&gt;&lt;BR /&gt;  (just doing my bit for the elimination of unnecessary temporary files ;-)&lt;BR /&gt;&lt;BR /&gt;On V8.3 and above, the CREATE can be written as:&lt;BR /&gt;&lt;BR /&gt;$ CREATE/FDL="RECORD; FORMAT STREAM_LF" sftp_dir.cmd&lt;BR /&gt;&lt;BR /&gt;  Also note that your procedure only works in batch, as sftp is sensitive to SYS$COMMAND. If executed interactively, the output is sent to the terminal, and an empty file is created. Further, it doesn't get around john's original problem - output from ls goes to SYS$OUTPUT and output from get goes to SYS$ERROR. If you add a GET command to your batch file, the GET output goes to the terminal and generates an empty output file (possibly obscuring the ls output).&lt;BR /&gt;&lt;BR /&gt;  The PIPE command, with the critically important "DEFINE/USER SYS$COMMAND NL:" will consolidate all output, and will behave the same as INTERACTIVE or BATCH.&lt;BR /&gt;&lt;BR /&gt;(I have no idea why SSH and SFTP behave so strangely with their output streams)</description>
      <pubDate>Tue, 18 Dec 2007 01:25:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117784#M13776</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2007-12-18T01:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117785#M13777</link>
      <description>&lt;!--!*#--&gt;Thanks John, here is the get extract. Works under ucx 5.4 eoc5 but not eco6. go figure :(&lt;BR /&gt;&lt;BR /&gt;Notice the user of define/user sys$error nl:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ open/write out sftp_bss_get.tmp  &lt;BR /&gt;$ write out "cd ''csa_output_directory'"&lt;BR /&gt;$ write out "lcd DIR:[INPUT_TMP]"&lt;BR /&gt;$ write out "get ''sftp_get_file_name'"&lt;BR /&gt;$ write out "quit"&lt;BR /&gt;$ close out &lt;BR /&gt;$!&lt;BR /&gt;$ convert/fdl=sys$input: sftp_bss_get.tmp sftp_bss_get.cmd&lt;BR /&gt;                        RECORD; FORMAT STREAM_LF&lt;BR /&gt;$! &lt;BR /&gt;$ type sftp_bss_get.cmd&lt;BR /&gt;$!&lt;BR /&gt;$ delete sftp_bss_get.tmp;&lt;BR /&gt;$ define/user sys$error nl:&lt;BR /&gt;$ sftp "-B" sftp_bss_get.cmd  -o "quietmode yes" secret@192.168.0.1 &lt;BR /&gt;</description>
      <pubDate>Tue, 18 Dec 2007 01:33:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117785#M13777</guid>
      <dc:creator>Thomas Ritter</dc:creator>
      <dc:date>2007-12-18T01:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117786#M13778</link>
      <description>&lt;!--!*#--&gt;Hi John, hi Thomas&lt;BR /&gt;&lt;BR /&gt;Let me express my gratitude for having worried about my problem. Unfortunately it was just before I leaved for the Christmas/New Year holidays, that's why my such late reply. Now, before re-entering the theme, let me wish you all&lt;BR /&gt;&lt;BR /&gt;A Happy New Year and all the best!:)&lt;BR /&gt;&lt;BR /&gt;Back to my SFTP problem, my actual "entry point" is a Perl script from which I have to open a SSH session with a (unix) server, transfer given files and delete them afterwards. As I could not find any Perl library SFTP module running on VMS, I had to deviate via the HP SFTP tool with its known intricacies.&lt;BR /&gt;I spent this morning testing your both variants. John's one works fine for me, Thomas' one, at least in my context, not.&lt;BR /&gt;Based on John's solution which embeds the call of the SFTP in a single PIPEd command I could, in turn, embed that command in a Perl system() call, as the excerpt below shows:&lt;BR /&gt;&lt;BR /&gt;my $fn_cmd = 'sftpcmd.txt';          #contains SFTP commands, eg. an 'ls' and more 'get's&lt;BR /&gt;my $flags = "\"-B\" $fn_cmd";&lt;BR /&gt;my $sftpstatus = "$host" . "_sftp_status";&lt;BR /&gt;my $fn_eo = 'sftp2vms_test_syssftp.log'; #SFTP output file&lt;BR /&gt;#&lt;BR /&gt;#build the system() call arguments:&lt;BR /&gt;my $sysarg = "PIPE (DEFINE/USER SYS\$COMMAND NL: ;SFTP $flags $user\@$host ;"; &lt;BR /&gt;$sysarg = $sysarg . "DEFINE/JOB/NOLOG $sftpstatus \&amp;amp;\$STATUS) | COPY SYS\$PIPE: $fn_eo";&lt;BR /&gt;print "...\'System\' command is: $sysarg\n";&lt;BR /&gt;&lt;BR /&gt;if ((my $call_stat=system($sysarg)) &amp;lt;0) {&lt;BR /&gt;   die "VMS PIPE/SFTP execution error, ret.code=$call_stat." ;&lt;BR /&gt;}&lt;BR /&gt;print "VMS PIPE/SFTP returned, ret.code=$call_stat.\n";&lt;BR /&gt;&lt;BR /&gt;On return from system() call sftp2vms_test_syssftp.log contains both the ls and get results. The host-specific logical &amp;lt;$host&amp;gt;_sftp_status allowing the evaluation of the SFTP execution could be retrieved by means of an existing VMS Perl module (I have to try it first).&lt;BR /&gt;&lt;BR /&gt;The Thomas' variant unfortunately does not work (under TCPIP V5.6-9ECO2 we currently have): the ls' output is correctly re-directed into a file, but the get's output is completely missing (neither in file nor on terminal)... Perhaps do I need some code more as in your excerpts, don't I Thomas? Or you have to add our TCPIP version to your exceptions list, haven't you?&lt;BR /&gt;&lt;BR /&gt;Whatever my test results are, you were both very helpful to me, so once again many thanks for your efforts for giving the HP forum an active life existence.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jan 2008 15:26:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117786#M13778</guid>
      <dc:creator>john nicoara</dc:creator>
      <dc:date>2008-01-07T15:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117787#M13779</link>
      <description>I'm having the exact same problem.  I need to capture the output from the SFTP ls command to a file so I can search it.&lt;BR /&gt;&lt;BR /&gt;When I do things the normal way:&lt;BR /&gt;$assign sys$output sftp.out&lt;BR /&gt;$sftp "-b" commands.dat user@node&lt;BR /&gt;$deassign sys$output&lt;BR /&gt;I get "Warning: Need basic cursor movement capablity, using vt100", and the output goes to the screen.&lt;BR /&gt;&lt;BR /&gt;As soon as I use DEFINE/USER SYS$COMMAND NL:, either in the pipe command or issued separately before the sftp command, I get "FATAL: OpenVMS$tty_gettty() failed&lt;BR /&gt;%TCPIP-F-SSH_FATAL, non-specific fatal error condition"&lt;BR /&gt;&lt;BR /&gt;Any idea why I'm getting the error, or any other way to redirect the output to a file?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Mar 2009 13:37:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117787#M13779</guid>
      <dc:creator>Dan Letobar</dc:creator>
      <dc:date>2009-03-13T13:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117788#M13780</link>
      <description>&lt;!--!*#--&gt;&amp;gt;  I'm having the exact same problem. [...]&lt;BR /&gt;&lt;BR /&gt;So, refer to the old, dead thread when you&lt;BR /&gt;start your own, new thread.&lt;BR /&gt;&lt;BR /&gt;Does adding '-o "batchmode yes"' to the&lt;BR /&gt;command do anything for you?</description>
      <pubDate>Fri, 13 Mar 2009 14:33:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117788#M13780</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-03-13T14:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Catching the SFTP output in a file</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117789#M13781</link>
      <description>Hi Dan,&lt;BR /&gt;see the John Gillings' solution above (Dec 18, 2007). It's tricky, but it works perfectly!</description>
      <pubDate>Mon, 16 Mar 2009 06:41:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/catching-the-sftp-output-in-a-file/m-p/4117789#M13781</guid>
      <dc:creator>john nicoara</dc:creator>
      <dc:date>2009-03-16T06:41:07Z</dc:date>
    </item>
  </channel>
</rss>

