Jump to content

Putty keeps my script from Completeing

OhioYJ
Go to solution Solved by elpiop,

You can use "start" to launch putty.exe in a new command prompt window.

 

start putty.exe -ssh root@192.168.1.4 -pw mypassword -m "C:\shutdown.txt"

 

I guess this sort of fits in the programming section? So I don't have issues on my Linux machines, however I have a couple PCs in the house that have Windows on them, need this script / batch file to run, I'm having an issue with this line:

 

putty.exe -ssh root@192.168.1.4 -pw mypassword -m "C:\shutdown.txt"

 

Contents of shutdown.txt:

shutdown -p +60

 

So that line should connect to the NAS shut it down, and then continue on with what it was doing. However nothing continues on until putty is closed (manually by hitting the "X" in the corner?).  My NAS does shutdown so that part works, however everything else stops at that point until. I'm sure I'm missing something basic right?

Link to comment
Share on other sites

Link to post
Share on other sites

If this is windows, rename the .txt file to .cmd

 

Slayerking92

<Type something witty here>
<Link to some pcpartpicker fantasy build and claim as my own>

Link to comment
Share on other sites

Link to post
Share on other sites

22 minutes ago, Slayerking92 said:

If this is windows, rename the .txt file to .cmd

 

It is, these lines are all in a .bat file (well not the .txt file obviously). My understanding was putty needs the commands it is supposed to be placed in a file. Changing the ending to a .cmd instead of .txt makes putty not run anything. It opens, but doesn't run the shutdown command.

Link to comment
Share on other sites

Link to post
Share on other sites

You can use "start" to launch putty.exe in a new command prompt window.

 

start putty.exe -ssh root@192.168.1.4 -pw mypassword -m "C:\shutdown.txt"

 

Link to comment
Share on other sites

Link to post
Share on other sites

11 minutes ago, elpiop said:

You can use "start" to launch putty.exe in a new command prompt window.

 

start putty.exe -ssh root@192.168.1.4 -pw mypassword -m "C:\shutdown.txt"

 

 

This doesn't close the putty window when complete, however it solves the problem. It lets the script continue on and shutdown the computer when complete, which is the important part. Thank you.

Link to comment
Share on other sites

Link to post
Share on other sites

13 minutes ago, OhioYJ said:

 

This doesn't close the putty window when complete, however it solves the problem. It lets the script continue on and shutdown the computer when complete, which is the important part. Thank you.

PuTTY can not be run in command line mode only, as far as I am aware. However, you can use "plink" which comes packaged with PuTTY. If you have the directory added to your path, you should just be able to run plink.exe to achieve the result you're looking for.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×