Executing (sudo) subcommands using Plink

核能气质少年 提交于 2019-12-06 11:23:35
sudo -i && cd /root/docker/storm-supervisor/ && ./stop-all.sh

Try your command in Linux shell. It won't work either. It will execute an elevated shell and wait for you to type commands. Only after you leave sudo shell, it will run the other commands (using the original account).

The cd and ./stop-all.sh are sub-commands of the sudo. So you have to treat them that way.

  • Best way is to provide the commands on sudo commandline:

    sudo "cd /root/docker/storm-supervisor/ && ./stop-all.sh"
    

    But that will probably require modifications of the sudoers file. Though it's the right way.

  • Or you will need to feed the commands to sudo input:

    echo "cd /root/docker/storm-supervisor/ && ./stop-all.sh && exit" | sudo
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!