Bash脚本运行参数不起作用的程序

时间:2014-05-31 09:50:43

标签: linux bash

您好,感谢您的阅读。 在使用Linux时我是初学者所以这个问题对你们大多数人来说可能看起来很无聊,但我无法在任何地方找到答案。 我尝试使用bash脚本运行6个程序,它们都需要将配置文件指定为参数。

这是我迄今为止所尝试过的:

#!/bin/bash
./shout/sc_serv "sc_serv.conf" &
./rshout/sc_serv "sc_serv.conf" &
./dshout/sc_serv "sc_serv.conf" &
./trans/sc_trans "sc_trans_dj.conf" &
./rtrans/sc_trans "sc_trans_dj.conf" &
./dtrans/sc_trans "sc_trans_dj.conf" &

这些会产生以下错误:

msg:[CONFIG] Could not find `sc_trans_dj.conf' - will now prompt for a config file to load
WARN [CONFIG] Could not find `sc_serv.conf' - looking for config file to load...

还尝试在配置中添加相同的路径,

#!/bin/bash
./shout/sc_serv "/shout/sc_serv.conf" &
./rshout/sc_serv "/rshout/sc_serv.conf" &
./dshout/sc_serv "/dshout/sc_serv.conf" &
./trans/sc_trans "/trans/sc_trans_dj.conf" &
./rtrans/sc_trans "/rtrans/sc_trans_dj.conf" &
./dtrans/sc_trans "/dtrans/sc_trans_dj.conf" &

但是它会给出同样的错误,

2014-05-31 12:44:54     WARN    [CONFIG] Could not find `/dshout/sc_serv.conf' - looking for config file to load...

路径是这样的:

/home/user/script
/home/user/shout/sc_serv
/home/user/shout/sc_serv.conf

等等。

在回答时,请记住,我正在寻找最简单的解决方案,因为我已经看过很多线索而且无法理解任何事情。我只是需要它来处理这个案例而不是一个普遍适用于所有事情的脚本,所以没有路径等等,如果我需要完整的路径,那也没关系

编辑::感谢您编辑我的帖子,我是新来的,不知道如何正确缩进内容

1 个答案:

答案 0 :(得分:0)

如果您在主目录中,我认为您的意思是:

#!/bin/bash
./shout/sc_serv "./shout/sc_serv.conf" &
...

注意添加。在开始。

另一种方法是改为给出绝对形式:

#!/bin/bash
./shout/sc_serv "/home/user/shout/sc_serv.conf" &
...