简体   繁体   中英

Running remotely Linux script from Windows and get execution result code

I have the current scenario to deal with: I have to schedule the backup of my company's Linux-based server (under Suse Linux) with ARCServe R15 (installed on Windows 2003R2SP2). I know I have the ability in my backup software (ARCServe) to add pre/post execution scripts to my backup-jobs. If failure of the script, ARCServe would be specified NOT to run the backup-job, and if success, specified to be run. I have no problem with this.

The problem is, I want to make a windows script (to be launched by ARCServe) for executing a Linux script on the cluster: - If this Linux-script fails, I want my windows-script to fail, so my backup job in ARCServe wouldn't run - If the Linux-script success, I want my windows-script to end normally with error code 0, so my ARCServe job would run normally. I've tried creating this batch file (let's call it HPC.bat):

echo ON

start /wait "C:\\Program Files\\PUTTY\\plink.exe" -v -l root -i "C:\\IST\\admin\\scripts\\HPC\\pri.ppk" [cluster_name] /appli/admin/backup_admin

exit %errorlevel%

If I manually launch this .bat by double-clicking on it, or launching it in a command prompt under Windows, it executes normally and then ends. If I make it being launched by ARCServe, the script seems never to end. My job stays in "waiting" status, it seems the execution code of the linux script isn't returned to my batch file, and this one doesn't close. In my mind, what's happening is plink just opens the connection to the Linux, send the sript execution signal, and then close the connection, so the execution code can't be returned to the batch. Am I right ?

Is what I want to do possible or am I trying something impossible to do ? So, do I have to proceed differently ? Do I have to use PUTTY or CygWin instead of plink ? Please, it's giving me headaches ...

If you install Cygwin, you could do it exactly like you can do it on Linux to Linux, ie remotely run a command with ssh someuser@remoteserver.com somecommand

This command will return with the same return code on the calling client, as the command exited with on the remote end. If you use SSH shared keys for authentication instead of passwords, it can also be scripted without user interaction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM