Plink is not returning to command prompt when exec

2019-09-02 07:33发布

I'm executing a command using Plink through a Perl file from a Windows machine.

system("cmd /c c:\\plink.exe -batch -ssh -l $user_name @ $host_name  -pw  $pwd start_http");

Execution is hanging. When I execute the same command from command prompt, Plink is not returning to command prompt.

Tried using & at the end of the command but no use. And I don't want to redirect output to any log file.

Whereas "stop" command is working fine

system("cmd /c c:\\plink.exe -batch -ssh -l $user_name @ $host_name  -pw  $pwd stop_http");

1条回答
Ridiculous、
2楼-- · 2019-09-02 07:44

stdout/err must be detached from the terminal.

So change command to

system("cmd /c c:\\plink.exe -batch -ssh -l $user_name @ $host_name  -pw  $pwd start_http /dev/null 2>&1 &");
查看更多
登录 后发表回答