简体   繁体   中英

Exit Plink when command finishes

I'm trying run multiple command lines via plink.exe . After batch is finished. I want to exit this and execute new command line

My script in execute.bat file

(
echo cd /appl/
echo sudo -s
echo cd apache-tomcat/webapps/Test
echo sh ./J50X100.sh
) | plink.exe -batch host -l user -pw pass

Actual: It's still in remote, I cannot execute new command line

这里的实际细节

Expected: Exit this and is able to execute new command line

The way you are using Plink, it opens an interactive shell session. As with every interactive shell session, it has to be exited with exit command. In you case, with two exit commands actually, first to exit sudo , then to exit the login shell.


Though you better avoid using the interactive shell altogether by specifying the command on Plink command line:

plink.exe -batch host -l user -pw pass "cd /appl/ ; sudo -s 'cd apache-tomcat/webapps/Test ; sh ./J50X100.sh '"

Though this approach might be problematic with your specific case, as you will have to configure sudo to allow this command - But you should do it, as it is the right approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM