从另一个脚本运行shell脚本 [英] running a shell script from another script
问题描述
我在UNIX脚本,看起来像这样:
I have a script in unix that looks like this:
#!/bin/bash
gcc -osign sign.c
./sign < /usr/share/dict/words | sort | squash > out
每当我尝试运行此脚本它给了我一个错误说,壁球不是一个有效的命令。壁球是存储在同一目录这个脚本的shell脚本,看起来像这样:
Whenever I try to run this script it gives me an error saying that squash is not a valid command. squash is a shell script stored in the same directory as this script and looks like this:
#!/bin/bash
awk -f squash.awk
我有正确执行权限设置,但由于某种原因,它不运行。有没有别的东西我必须做的,使它能够运行像显示?我是相当新的脚本所以任何帮助将不胜AP preciated!
I have execute permissions set correctly but for some reason it doesn't run. Is there something else I have to do to make it able to run like shown? I am rather new to scripting so any help would be greatly appreciated!
推荐答案
正如上文@比芬的评论,除非。
是在 $ PATH
变量,你需要指定 ./壁球
你需要指定同样的原因 ./签署
。
As mentioned in @Biffen's comment, unless .
is in your $PATH
variable, you need to specify ./squash
for the same reason you need to specify ./sign
.
在命令行上解析裸字,庆典将检查 $ PATH中列出的所有目录
来看看说字是一个可执行文件的生活中的任何人。除非。
是 $ PATH
时,bash不会找到壁球
。
When parsing a bare word on the command line, bash checks all the directories listed in $PATH
to see if said word is an executable file living inside any of them. Unless .
is in $PATH
, bash won't find squash
.
要避免这个问题,你可以告诉bash不能去给予的bash它的完整路径寻找壁球
,即 ./壁球
。
To avoid this problem, you can tell bash not to go looking for squash
by giving bash the complete path to it, namely ./squash
.
这篇关于从另一个脚本运行shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!