如何修复linux中的脚本? [英] how do fix script in linux?
问题描述
嗨
如何修复和运行linux中的脚本?
如果找到/ u01 / monitor /列表;然后
回显找到路径。
elif mkdir -p / u01 / monitor / list;然后
回显Path not fount; Path Created!
fi
year =date +%y
而[$ year ==15]
do
ps -e> ; /u01/monitor/list/Process-data.txt
if grep'firefox'/u01/monitor/list/Process-data.txt;then
echonot found !!
睡60美元b $ b elif firefox;然后
echo启动firefox
完成
< blockquote> year ==15]
do
ps -e> /u01/monitor/list/Process-data.txt
if grep'firefox'/ u01 / monitor / list /Process-data.txt;然后
echonot found !!
睡60美元b $ b elif firefox;然后
echo启动firefox
完成
究竟是什么意思通过修复并运行?
但是,有一些错误:
在第一个中指定shell脚本的行(常见的是bash和sh):
#!/ bin / sh
##在这里使用/ bin / sh因为这是一个链接到使用的shell
while循环将永远或永久执行,具体取决于
year (最初可能不是15,在循环中永远不会更改)。
行elif firefox;然后必须修复。可能没有变量
firefox
,分号和之间应该有空格,然后
。
缺少fi
(在完成
之前) while)
最后使用扩展名 .sh 保存您的脚本(编辑:不是必需但是最佳做法)并使其可执行:
chmod 775< script-name>
hi
how do fix and run script in linux?
if find /u01/monitor/list; then echo "Path found." elif mkdir -p /u01/monitor/list; then echo "Path not fount ; Path Created!" fi year="date +"%y"" while [$year=="15"] do ps -e >/u01/monitor/list/Process-data.txt if grep 'firefox' /u01/monitor/list/Process-data.txt;then echo "not found !!" sleep 60 elif firefox;then echo "launch firefox" done
year=="15"] do ps -e >/u01/monitor/list/Process-data.txt if grep 'firefox' /u01/monitor/list/Process-data.txt;then echo "not found !!" sleep 60 elif firefox;then echo "launch firefox" done
What exactly do mean by fix and run?
However, there are some errors:
Specify the shell in the first line of the script (common are bash and sh):
#!/bin/sh ## Use /bin/sh here because that is a link to the used shell
The while loop will execute never or forever depending on
year (may be not 15 initially and when it is never changed inside the loop).
The lineelif firefox;thenmust be fixed. There is probably no variable
firefox
and there should be space between the semicolon andthen
.
There is afi
missing (before thedone
from the while)
Finally save your script with the extension .sh (EDIT: not necessary but best practice) and make it executable:
chmod 775 <script-name>
这篇关于如何修复linux中的脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!