Execute Script using an Alias
我正在尝试创建一个将执行脚本的别名。当我cd进入脚本所在的目录...假设说/ usr / local / bin / startscript时,脚本将按预期运行,并启动我想要的应用程序。
SO。我进入我的bashrc文件并添加了别名
别名startscript ='/ usr / local / bin / startscript'
目标是能够通过在任何目录中简单键入" startscript"来运行脚本。
但是,当我尝试使用别名来运行脚本时,它不能正常运行,因为应该启动的应用程序不能正常运行。
我的脚本以
开头
1 | #!/bin/sh |
然后从那里去
有什么想法吗?谢谢
脚本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/sh #- Check for user 'user' if [["`whoami`" !="user" ]]; then echo"This script can only be executed by user 'user'."; exit fi . /usr/local/bin/etctrx/startscriptdirectory/startscriptsetup #- Kill manager to avoid multiple processes pkill -f 'JavaApp.jar' #- Start nohup java -classpath /usr/local/bin/etctrx/startscriptdirectory/RequiredJars/ojdbc5.jar:/usr/local/bin/etctrx/startscriptdirectory/RequiredJars/activation.jar:/usr/local/bin/etctrx/startscriptdirectory/RequiredJars/mail.jar -jar /usr/local/bin/etctrx/startscriptdirectory/JavaApp.jar > ${JAVAAPPLOGS}/startscript.log 2>&1 & |
如果通过简单键入
正如其他人所指出的,您不必为
I am able to call the script if i do this, but it still won't give me the
results I want,(application being started) like i do when I run the script from
the directory it lives in
看来,所讨论的"应用程序"与脚本"
1 | ./application |
除非您从
1 | application |