从另一个脚本运行shell脚本 [英] running a shell script from another script

查看:130
本文介绍了从另一个脚本运行shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆