Operating System - OpenVMS
1820095 Members
3488 Online
109608 Solutions
New Discussion юеВ

Re: Redirecting SSH output

 
SOLVED
Go to solution
Tom Musson
Advisor

Re: Redirecting SSH output

Gerhard,

I have one more thing that might interest you. I find that I am getting the exit status from the remote ssh command. If I execute the ssh command with the -v flag, I can see the exit status of the remote command. Note that the exit status of 0 is translated to 1, but other codes are sent back with the Unix value.

$ ssh -v user@host "env"
o
o
o
debug: Ssh2Common/SSHCOMMON.C:697: num_channels now 0
debug: Got session close with exit_status=0
debug: destroying client struct...

debug: uninitializing event loop
$ show sym $status
$STATUS == "%X00000001"
$ ssh -v user@host "invalid"
o
o
o
debug: Got session close with exit_status=127
debug: destroying client struct...

debug: uninitializing event loop
$ show sym $status
$STATUS == "%X0000007F"

All of this is to say that the VMS-side may not be your problem.

Regards,

Tom
Gerhard Olsson
Advisor

Re: Redirecting SSH output

Thanks Tom

I had already changed the Solaris side scripts to print the exit status so guess I stick with that. In addition to the exit status, the remote scripts writes a reason. However, this tip is useful if I do changes.

One thing about changes, why I cannot redirect but Tom can (I tested this immediately but I now saw that I forgot to write about this).
The difference is not tcsh (that the Solaris account use by default) versus bash (I assume bash, since Tom use Linux). The syntax differ of course, but even if I change to bash, redirect does not work.

Gerhard
Galen Tackett
Valued Contributor

Re: Redirecting SSH output

Gerhard and others,

FWIW, SPAWN/OUTPUT doesn't help any here either. It just creates an empty output file.

This is probably to be expected in view of what previous responses have reported as not helping (logical name definitions, PIPE, etc.)
Tom Musson
Advisor
Solution

Re: Redirecting SSH output

Gerhard, et al,

One other thing I have discovered about my stderr redirection is that it does not work if I execute the ssh command interactively, but does work if the command is included in a batch procedure.

In any case, since I get a non-ss$_normal return status, I don't really need to capture the output to analyze it. I just test that status and report that an exception occured that must be investigated.

Regards,

Tom
Gerhard Olsson
Advisor

Re: Redirecting SSH output

Thanks Tom, this solves my problem, since command procedure to collect statiscts is running in batch already.

Actually, I thought I tested batch mode before asking the first question, but I must have missed this in the frustration.

The functionality is weird.....

Gerhard
Jeremy Stubbs
Occasional Advisor

Re: Redirecting SSH output

The key with BATCH mode is to actually submit the job to a BATCH queue with /LOG

You then don't redirect SYS$OUTPUT, but anything written to it should be in the BATCH job logfile.

e.g.

$> type check2.com
$ ssh stubbsj@dannii "@timestamp"
$ EXIT
$>

$> submit/queue=sys$batch check2.com /notify

$> type check2.log
$ Set NoOn
$! write sys$output "running sylogin"
$! def/user sys$input sys$command
$! set password
$ VERIFY = F$VERIFY(F$TRNLNM("SYLOGIN_VERIFY"))

17-JAN-2005 11:45:34
Disconnected; connection lost (Connection closed.).
Gerhard Olsson
Advisor

Re: Redirecting SSH output

Jeremy, since the "statistics collecting" is running in batch already, I have to submit a new batch job as explained in my workaround.

Since exit status 0 is changed to 1, the exit code translation is not really helping. "exit 1" is used in most scripts... Transferring error codes from one platform to another is not easy. This is probably why it is deactivated by default. I would rather have the raw output and use "SET NOON".

In my "live" scripts, redirection does not work in batch mode. I will stick with my workaround (extra submit and exit code with "tag" in output).
Thanks Tom for the workaround anyway.

/Gerhard
Gerhard Olsson
Advisor

Re: Redirecting SSH output

Redirection works in batchmode (only) in TCPIP 5.4 ECO 5
The "extra submitt" step can now be removed.
/Gerhard