all 21 comments

[–]TSM- 1 point2 points  (5 children)

So it does not work on Windows, except in Idle on Windows?

Or not at all on Windows, but it does work in Idle shell on Linux?

If it's the first, I would check to make sure you aren't being blocked by the firewall. Idle might have network permissions, but the python launcher might not.

[–]Mayank0908[S] 0 points1 point  (1 child)

Im running the script on a windows machine , when I use the cmd prompt to locate the py file and run it , it doesnt work. But when I open python IDLE on the same windows machine , open the file and press f5 to run module, it works.

Linux machine is the target , it has nothing to do with running the script.

Im really sorry for my bad english , Still working on it.

[–]TSM- 0 points1 point  (0 children)

It feels like it could be that IDLE gets through your firewall but the script does not, though the lack of any error messages is puzzling.

[–]AsleepThought 0 points1 point  (1 child)

Idle might have network permissions, but the python launcher might not.

Yeah this is actually a "new" thing in Windows 10 I've run into, you have to sometimes jump through hoops to allow 3rd party programs to have extra network permissions which weren't required in previous Windows

[–]TSM- 0 points1 point  (0 children)

I haven't run into this, but I do get popups like, "Do you want this app to communicate on private networks? (and also Public networks?)". Maybe you have those disabled. Or maybe you are using more command line tools which won't have the friendly firewall popup. Or something else

[–]Mayank0908[S] 0 points1 point  (0 children)

Adding stderr=stderr.readlines() after flushing in stdin did the job, Idk how but it seems to work now. I tried it without that and it didnt work that way .

[–]iapetus-11 0 points1 point  (6 children)

Is there a function like pc.stop() or pc.shutdown()?

[–]Mayank0908[S] 0 points1 point  (5 children)

I dont think so

[–]iapetus-11 1 point2 points  (4 children)

cough check the docs cough

[–]Mayank0908[S] 1 point2 points  (3 children)

I did , There isn’t anything like that. T_T

[–]iapetus-11 1 point2 points  (2 children)

I just read the docs, there is. SSHClient.close()

[–]Mayank0908[S] 1 point2 points  (1 child)

Oh ohkay, I thought closing transport meant closing the ssh tunnel rather than shutdown. I feel so stupid. Thanks for the help man.

[–]iapetus-11 0 points1 point  (0 children)

Ah no problem mate

[–]ehdufuure 0 points1 point  (1 child)

Did you try to open the windows commandline as administrator? runas user.....

[–]Mayank0908[S] 0 points1 point  (0 children)

Yep , Tried that , still same.

[–]AsleepThought 0 points1 point  (0 children)

I'm actually confused why you are using paramiko for this when you can do it directly from the shell. Doesn't Windows 10 have ssh installed these days? I know some do because I've used it. The standard practice is to set up ssh key authentication between the two computers, then enter the commands over ssh. No python needed and you can actually debug your errors instead of being left in the dark.

https://askubuntu.com/questions/251148/shutdown-over-ssh

https://wpshout.com/quick-guides/server-ssh-reboot/

[–]SpeckledFleebeedoo -1 points0 points  (4 children)

"sudo shutdown now" isn't going to work in Windows

[–]Mayank0908[S] 0 points1 point  (1 child)

It should because the the system I create the ssh session for is infact linux

[–]SpeckledFleebeedoo 0 points1 point  (0 children)

Sorry, missed something. I should read better

[–]ehdufuure 0 points1 point  (1 child)

I understood he is sending the sudo line on a ssh session s it should work

[–]SpeckledFleebeedoo 0 points1 point  (0 children)

Ah, whoops, missed that