分页: 1 / 1

关于shell转向后台的问题

发表于 : 2008-12-22 11:02
ambisher
我是新手,请教大家一个问题,为了在ubuntu下运行华为上网客户端,我写了一个shell文件,代码如下
#!/bin/sh

echo "*************************************"
echo " this is the first shell "
echo "*************************************"
echo

if [ "`whoami`" = "root" ]; then
echo "对不起,请不要使用root帐户或者sudo命令运行。"
exit 1
fi
cd /home/ambisher/H3C
sudo ./h3c8021xclient
echo
key=""
echo -n "按任意键继续..."
stty -icanon
key=`dd count=1 2>/dev/null`
stty icanon


可运行起来,可是连接完之后一关闭终端窗口就会把网络也断掉 ,怎么让它能够联网后自动转向后台。

希望哪位高手能帮我修改一下代码!先谢过了!

Re: 关于shell转向后台的问题

发表于 : 2008-12-22 11:29
eexpress
ttyx / screen / dtach / bg / &

Re: 关于shell转向后台的问题

发表于 : 2008-12-22 12:33
aBiNg
Ctrl - z

Re: 关于shell转向后台的问题

发表于 : 2008-12-23 10:18
bones7456
已经是root了,就别sudo了。

Re: 关于shell转向后台的问题

发表于 : 2008-12-25 16:56
cnkilior
放到rc.local中自动运行。

Re: 关于shell转向后台的问题

发表于 : 2008-12-27 13:34
cnkilior
刚找到的一个方法:setsid CMD