Automatically execute a command in PuTTY opened from WinSCP

1

1

I am using WinSCP with PuTTY and I have setup an auto login to PuTTY from WinSCP. I have a bat file that opens the WinSCP and several connections to remote machines and once the WinSCP connects it also automatically opens the PuTTY.

What I want is to send command top to the PuTTY after login. Is there any way to do it ?

I am monitoring several Linux servers. I want that after the PC starts up, it automatically opens PuTTY console with and send a top command.

Dakado

Posted 2016-03-14T13:04:10.220

Reputation: 105

Answers

1

In the WinSCP preferences go to the Integration > Applications page.

There specify the following command in the PuTTY/Terminal client path box:

"%PROGRAMFILES%\PuTTY\putty.exe" -t -m "%TEMP%\putty.txt" !`cmd.exe /c echo top > "%TEMP%\putty.txt"`

It follows the same approach as suggested for opening PuTTY in the same directory in WinSCP documentation. Just instead of the cd command, use the top. For details see the link.

Martin Prikryl

Posted 2016-03-14T13:04:10.220

Reputation: 13 764

Well, but there is one problem, later if I want to start up another season of putty for something different than watching top I cannot leave the top because once I do ctrl+c the session and entire putty windows is closed. – Dakado – 2016-03-15T20:54:28.677

Replace the top with top ; /bin/bash to start a bash shell after you terminate the top. – Martin Prikryl – 2016-03-16T06:50:08.360