开发者

Shell script - exiting before completion

I have made a short shell script which launches a VM, sleeps some time to allow the VM to boot and then mounts a share at the VM on the host computer:

#!/bin/bash
nohup VBoxManage startvm "Ubuntu server" --type headless &&
sleep 60 &&
sudo mount -t cifs //192.168.1.1/www /media/ubuntuserver/ 

The VM is started properly and the script sleeps but no mount occurs and the script seems to j开发者_开发技巧ust exit instead. What am I doing wrong?


is your sudo mount working in non-interactive mode? make sure this command is not asking any password

Add some logging so that you know what output is being returned

#!/bin/bash
nohup VBoxManage startvm "Ubuntu server" --type headless 2>&1 >> ~/script_log.txt &&
sleep 60 2>&1 >> ~/script_log.txt &&
sudo mount -t cifs //192.168.1.1/www /media/ubuntuserver/ 2>&1 >> ~/script_log.txt 

replace ~/script_log.txt with any suitable log file path

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜