- Статус темы:
-
Закрыта.
-
Помогите пишу в start.sh :
#!/bin/bashBINDIR=$(dirname «$(readlink -fn «$0″)»)
cd «$BINDIR»while true
do
java -Xincgc -Xms1024M -Xmx1024M -jar craftbukkit.jarecho -e ‘If you want to completely stop the server process now, press ctrl-C before thentime is up!’
echo «Rebooting in:»
for i in {5..1}
do
echo «$i…»
sleep 1
done
echo ‘Restarting now!’
и пишет Syntax error: end of file unexpected (expecting «done»)
Помогите исправить ошибку
P.S. Я в этом 0 ) -
почему два «do», echo после done? криво
-
Можешь скинуть готовый вариант плиз
-
Хватит сдуваться!!!
Уйди с говно хостинга(loadvirus) на каждой vps/vds вирус сдувают вас там переходи вот на этот
else
иди играй в казино рулетку европейскую -
Vedroyder и caNek нравится это.
-
#!/bin/bash BINDIR=$(dirname "$(readlink -fn "$0")") cd "$BINDIR" while true do echo 'Restarting now!' java -Xincgc -Xms1024M -Xmx1024M -jar craftbukkit.jar echo -e 'If you want to completely stop the server process now, press ctrl-C before thentime is up!' echo "Rebooting in:" for i in {5..1} # тут был do echo "$i..." sleep 1 done
попробуй так
-
Теперь так) Syntax error: end of file unexpected (expecting «do»)
-
#!/bin/bash BINDIR=$(dirname "$(readlink -fn "$0")") cd "$BINDIR" while true ; do echo 'Restarting now!' java -Xincgc -Xms1024M -Xmx1024M -jar craftbukkit.jar echo -e 'If you want to completely stop the server process now, press ctrl-C before thentime is up!' echo "Rebooting in:" for i in {5..1} echo "$i..." sleep 1; done
точку с запятой забыл
Сникерсни и gasfull нравится это.
-
Syntax error: word unexpected (expecting «do»)
-
методом тыка выяснил что виновата эта строчка for i in {5..1}, непонимаю зачем она нужна?
-
Скинь готовый вариант))плиз
-
все, до меня доепрло
#!/bin/bash BINDIR=$(dirname "$(readlink -fn "$0")") cd "$BINDIR" while true ; do echo 'Restarting now!' java -Xincgc -Xms1024M -Xmx1024M -jar craftbukkit.jar echo -e 'If you want to completely stop the server process now, press ctrl-C before thentime is up!' echo "Rebooting in:" for i in {5..1} do echo "$i..." sleep 1; done done
совсмем невнимательный, у цикла for надо было done написать)
а вот команду запуска я бы поменялjava -Xincgc -Xms512M -Xmx1024M -jar craftbukkit.jar
а то всю память сожрет и отвалится
-
СПАСИБО ТЕБЕ ОГРОМНОЕ!
- Статус темы:
-
Закрыта.
Поделиться этой страницей
Здравствуйте! При попытке запустить это чудо в WSL возникает ошибка.
app.sh: 5: Syntax error: word unexpected (expecting «do»)
ad=/path/endfile.mp4
clips_in=/path/
clips_out=/tmp/
for clip in $clips_in/*.mp4; do
nm=`basename $clip .mp4`
cat | ffmpeg -f concat -i - -c:v copy -c:a copy $clips_out/${nm}_out.mp4 << EOF
file $clip
file $ad
EOF
done
-
Вопрос заданболее года назад
-
294 просмотра
Пригласить эксперта
Перенеси «do» в четвертой строке на следующую строку.
Блин, ну вас в гугле забанили, что ли?
https://www.cyberciti.biz/faq/bash-for-loop/
Смотрим синтаксис:
for VARIABLE in $(Linux-Or-Unix-Command-Here)
do
command1
command2
commandN
done
Видим:
— do на следующей строке после for
— перед do нет ;
Еще, подозреваю, вместо $clips_in/*.mp4
понадобится вызов find с этим параметром; но это не точно
bash и sh — это разные оболочки. используйте баш для запуска скрипта.
-
Показать ещё
Загружается…
15 апр. 2023, в 02:02
12000 руб./за проект
14 апр. 2023, в 23:12
8000 руб./за проект
14 апр. 2023, в 23:01
10000 руб./за проект
Минуточку внимания
I’m trying to run this dropbox script on my nginx server , but im getting:
Syntax error: word unexpected (expecting "do")
I copy pasted the script for a website, and I tried removing special characters, but im still getting the same error.
script:
#!/bin/sh
# /etc/init.d/dropbox
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $network $syslog $remote_fs
# Required-Stop: $network $syslog $remote_fs
# Should-Start: $named $time
# Should-Stop: $named $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the dropbox daemon for debian/ubuntu
# Description: Dropbox daemon for linux
### END INIT INFO
DROPBOX_USERS="root"
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
start-stop-daemon -b -o -c $dbuser -S -x /home/$dbuser/.dropbox-dist/dropboxd
done
}
stop() {
echo "Stopping dropbox..."
for dbuser in $DROPBOX_USERS; do
start-stop-daemon -o -c $dbuser -K -x /home/$dbuser/.dropbox-dist/dropboxd
done
}
status() {
for dbuser in $DROPBOX_USERS; do
dbpid=`pgrep -u $dbuser dropbox`
if [ -z $dbpid ] ; then
echo "dropboxd for USER $dbuser: not running."
else
echo "dropboxd for USER $dbuser: running."
fi
done
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
stop
start
;;
status)
status
;;
*)
echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}"
exit 1
esac
exit 0
asked Apr 3, 2014 at 22:03
4
Probably you managed to insert windows line endings when you copy and pasted. If you have dos2unix, use it. (dos2unix scriptfile) Otherwise, there are a number of similar utilities.
answered Apr 3, 2014 at 22:13
ricirici
232k28 gold badges234 silver badges338 bronze badges
3
Why do you have
/home/$dbuser/.dropbox-dist/dropboxd
or replacing variables.
/home/root/.dropbox-dist/dropboxd
Shouldn’t it be
/root/.dropbox-dist/dropboxd
eg
/$dbuser/.dropbox-dist/dropboxd
Are you seriously allowing dropboxes in /root
?
Also why a for dbuser in DROPBOX_USERS; do
reassign? rather than
dbuser=$DROPBOX_USERS
answered Apr 6, 2014 at 10:41
1
I am trying to execute this simple bash script but I am getting a syntax error. I followed this simple documentation here https://www.cyberciti.biz/faq/bash-for-loop/ but no luck. I am not sure what am I doing wrong?
#!/bin/bash
for i in 1 2 3 4 5
do
echo "Count $i"
done;
error:
setup.sh: 3: setup.sh: Syntax error: word unexpected (expecting "do")
I am executing that script from my Windows Subsystem Linux (WSL) here.
Kusalananda♦
312k35 gold badges614 silver badges909 bronze badges
asked Apr 26, 2018 at 12:56
3
Your script file is a DOS text file. The extra carriage returns at the end of each line confuses bash
(it sees dor
rather than do
).
Convert it to a Unix text file using a tool such as dos2unix
, or make sure that your editor saves it as a Unix text file.
answered Apr 26, 2018 at 13:03
Kusalananda♦Kusalananda
312k35 gold badges614 silver badges909 bronze badges
2
I just executed same script in my centos machine which works file. As suggested by Kusalananda, convert the script file from dos to unix. install dos2unix package if you do not have it installed already. Then you can use below command to convert
$dos2unix (name of the file)
tachomi
7,2024 gold badges24 silver badges45 bronze badges
answered Apr 26, 2018 at 13:14
#!/bin/bash
for i in 1 2 3 4 5
do
echo "Count $i"
done;
A better way to loop would be:
for i in {1..5}; do
echo "Count $i";
done
This way you do not have to specify all of those numbers. So what would you do if you had to loop through 100 numbers using your method?
answered Apr 26, 2018 at 15:21
- Forum
- The Ubuntu Forum Community
- Ubuntu Official Flavours Support
- New to Ubuntu
- [ubuntu] Syntax error: word unexpected (expecting «do»)
-
Syntax error: word unexpected (expecting «do»)
Hi! i am writting a code to delete excel reports older than one day.
The code is as follows:path=»/home/directory/Reports»
echo «The reports older than one day are getting deleted…»
for i in `find $path/*.xls -mtime +1 -print`
do
echo «File $i is deleted»
sudo rm $i
done
echo «Deletion is completed»When i am executing this script, it is giving me the error that
Syntax error: word unexpected (expecting «do»)but if i write the same code on command prompt instead of in shell script, it is getting executed properly. Please let me know where i am getting wrong.
Thanks in advance
-
Re: Syntax error: word unexpected (expecting «do»)
Put this in the first line of your script file:
#!/bin/sh
This sets which interpreter you are using (in this case, sh, or bash). This
may solve the problem. I cannot see anything else now.Just for curiosity: Do you really need root privileges to delete the files? (Is the use of «sudo» necessary, it seems strange, and dangerous).
-
Re: Syntax error: word unexpected (expecting «do»)
The other thing, if that doesn’t solve it, is that you might need a semicolon at the end of the for line.
Also, if you post code, you can put it inside tags to make it formatted so its easier to read. Its ok here but helps for longer snippets. Just put it inside [code] and [/code] tags
-
Re: Syntax error: word unexpected (expecting «do»)
Well, even after adding #!/bin/sh, the code is giving same error.
The code snippet is as follows:
Code:
#!/bin/sh path="/home/directory/Reports" echo "The reports older than one day are getting deleted..." for i in `find $path/*.xls -mtime +1 -print`; do echo "File $i is deleted" rm $i done echo "Deletion is completed"
The output is as follows:
$sh Reportremoval.sh
The reports older than one day are getting deleted…
Reportremoval.sh: 5: Syntax error: word unexpected (expecting «do»)Please give me some suggestion.
Last edited by rohandeshmukh; April 21st, 2009 at 06:28 AM.
-
Re: Syntax error: word unexpected (expecting «do»)
I think it needs more semicolons You can never have too many. When you type it in the shell it adds them automatically, so put them after the «echo» and «rm» lines.
Edit: It also occurred to me that this could be made much easier — find has a delete option:
Code:
find $path/*.xls -mtime +1 -delete
-
Re: Syntax error: word unexpected (expecting «do»)
I think the proble was associated with the permission. I changed the user name and re-executed the same script and this time it worked fine!
anyways, Thanks for your help!