Originally run was a good document, amended in the windows, and then ported to linux on the error.
Looking for a lap Here are solutions:
The reason this happens is because your file is processed line breaks dos format "\ r \ n"
You can use cat -v filename to see if a line break is, if it is above, it would be the end of the line ^ m
need to convert linux / unix format "\ n"
specific conversion is line feed conversion procedures
can be handled at the file with sed command, the command is as follows:
sed 'S / \ R & lt //' after the original file> file conversion
Check the shell syntax
[root@iZm5ed2begvgw01qrymv8yZ Data]# bash -n task_start.sh
task_start.sh: line 4: syntax error near unexpected token `$'do\r''
'ask_start.sh: line 4: `do
[root@iZm5ed2begvgw01qrymv8yZ Data]#
I have found that there is no execution
[root@iZm5ed2begvgw01qrymv8yZ Data]# sed 's/\r//g' task_start.sh > task_start.sh
[root@iZm5ed2begvgw01qrymv8yZ Data]#
[root@iZm5ed2begvgw01qrymv8yZ Data]#
[root@iZm5ed2begvgw01qrymv8yZ Data]#
[root@iZm5ed2begvgw01qrymv8yZ Data]# [root@iZm5ed2begvgw01qrymv8yZ Data]# cat task_start.sh -v [root@iZm5ed2begvgw01qrymv8yZ Data]# cat task_start.sh
The reason
???
solve
[root@iZm5ed2begvgw01qrymv8yZ Data]# sed 's/\r//g' task_start.sh > task_start2.sh
[root@iZm5ed2begvgw01qrymv8yZ Data]#
[root@iZm5ed2begvgw01qrymv8yZ Data]#
[root@iZm5ed2begvgw01qrymv8yZ Data]# cat task_start2.sh
#!/usr/bin/env bash task_url=("http://hs.oeynet.com/task.php" "http://hs.oeynet.com/task.php") for n in `seq 10` do for task in ${task_url[*]} do curl $task >> /www/server/logs/task.log done sleep 6 done [root@iZm5ed2begvgw01qrymv8yZ Data]# cat task_start2.sh -v