How to ignore/suppress errors while trying to execute command from PuTTY through cmd

934 views Asked by At

I want to lock my arch laptop using .bat file on my Windows machine.

I wrote this in my batch:

start C:\some_path\putty.exe -load "naptop@nick" -m C:\some_path\remote.cmd

And remote.cmd contains:

xfce4-session-logout --suspend;exit 0;

It works perfect! But when I don't have an internet connection, I have an error:

screen

Can I somehow ignore any errors when script can't execute my command?

1

There are 1 answers

1
Martin Prikryl On BEST ANSWER

Do not use PuTTY for automating command execution.

Use Plink (part of PuTTY package). It takes the same arguments as PuTTY. Additionally you will want to add -batch switch to skip any prompts that you may get.

C:\some_path\plink.exe -batch -load "naptop@nick" -m C:\some_path\remote.cmd

With Plink you can even specify your command directly on its commandline:

C:\some_path\plink.exe -batch -load "naptop@nick" xfce4-session-logout --suspend;exit 0;