Errorlevel capturing from plink?
I am able to connect via SSH to my server and run remote commands.
This seems to work fine interactively and so now I am trying create a
script to automate some commands. I am using plink with a command line
plink -batch -i c:\myppk.ppk user@server cmd /c c:\temp
The connection works fine, and the command file does execute on the
remote server. However, my problem is that if the remote command file
fails for any reason, I don't seem to be able to capture this via an
errorlevel locally in my script. Plink always seems to return an
errorlevel = 0, even when I have redirected the errorlevel on the
server to a file and know it is non-zero. The commandfile.cmd on the
server currently finishes with:
Am I doing something obviously wrong?
Thanks in advance,
Re: Errorlevel capturing from plink?
In case anyone is interested, I have "solved" this problem by echoing
the exit errorlevel code from the remotely executed command file to a
log file. I can then transfer the log file to the local machine (using
pscp) and read the contents.
I have created a Python script which takes appropriate command line
arguments to do this somewhat generically (on the assumption the
expected log file is created) and exits itself with the errorlevel
derived from the remote command.