您好,感谢您的阅读。 我是一个使用 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
等等。
请记住,在回答时,我正在寻找最简单的解决方案,因为我已经看到了很多线程并且无法理解任何内容。我只需要它适用于这种情况,而不是一个普遍适用于所有情况的脚本,因此没有路径获取等等,如果我需要完整路径,那也很好
编辑::感谢您编辑我的帖子,我是新来的,不知道如何正确缩进
最佳答案
如果您位于主目录中,我认为您的意思是:
#!/bin/bash
./shout/sc_serv "./shout/sc_serv.conf" &
...
注意添加的 .在开始时。
另一种方法是给出绝对形式:
#!/bin/bash
./shout/sc_serv "/home/user/shout/sc_serv.conf" &
...
关于linux - Bash 脚本运行带参数的程序不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23968594/