如何修复linux中的脚本? [英] how do fix script in linux?

查看:154
本文介绍了如何修复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 line

elif firefox;then

must be fixed. There is probably no variable firefox and there should be space between the semicolon and then.

There is a fi missing (before the done 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屋!

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