+ -
当前位置:首页 → 问答吧 → 这么个小问题我都没搞定,在线等

这么个小问题我都没搞定,在线等

时间:2011-01-11

来源:互联网

很简单的啦,就是  
cd   /usr/local/batch/office/bin  
nohup ./startserver.sh &

这样子2步用perl的system写,可我都写得不对
#!/usr/bin/perl
system(cd   /usr/local/batch/office/bin);
system(nohup ./startserver.sh &);

  ---这样执行不了的吧?我改成:

#!/usr/bin/perl
system "cd","/usr/local/batch/office/bin";
system "nohup","./startserver.sh","&";

  ---这样好像也不行,我对这个调用的内部实现还不清楚,所以不知道怎么写,在线等,谢谢。
---顺便说下,我有3个要执行,所以写批处理文件,因为刚学perl要利用起来。

作者: 穆赫兰道   发布时间: 2011-01-11

回复 穆赫兰道


直接执行/usr/local/batch/office/bin/startserver.sh,
你system里面cd是cd不到那里去的

作者: Perl_Er   发布时间: 2011-01-11

回复 穆赫兰道
切换工作目录,用chdir

作者: atiking   发布时间: 2011-01-11

上面的方法都不错的
另外,多个命令可以合在一个语句里:
cd  /usr/local/batch/office/bin && nohup ./startserver.sh &

作者: yiten   发布时间: 2011-01-11