Word unexpected expecting done

Скрыть объявление

В преддверии глобального обновления, мы проводим исследования, которые помогут нам сделать опыт пользования форумом ещё удобнее. Помогите нам, примите участие!
Статус темы:

Закрыта.
  1. Помогите пишу в start.sh :
    #!/bin/bash

    BINDIR=$(dirname «$(readlink -fn «$0″)»)
    cd «$BINDIR»

    while true
    do
    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
    echo ‘Restarting now!’
    и пишет Syntax error: end of file unexpected (expecting «done»)
    Помогите исправить ошибку
    P.S. Я в этом 0 )

  2. почему два «do», echo после done? криво

  3. Можешь скинуть готовый вариант плиз

  4. Хватит сдуваться!!!
    Уйди с говно хостинга(loadvirus) на каждой vps/vds вирус сдувают вас там переходи вот на этот
    else
    иди играй в казино рулетку европейскую


  5. Vedroyder и caNek нравится это.
  6. #!/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

    попробуй так

  7. Теперь так) Syntax error: end of file unexpected (expecting «do»)

  8. #!/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 нравится это.
  9. Syntax error: word unexpected (expecting «do»)

  10. методом тыка выяснил что виновата эта строчка for i in {5..1}, непонимаю зачем она нужна?

  11. Скинь готовый вариант))плиз

  12. все, до меня доепрло

    #!/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

    :eek:совсмем невнимательный, у цикла for надо было done написать)
    а вот команду запуска я бы поменял

    java -Xincgc -Xms512M -Xmx1024M -jar craftbukkit.jar

    а то всю память сожрет и отвалится

  13. СПАСИБО ТЕБЕ ОГРОМНОЕ! :)

Статус темы:

Закрыта.

Поделиться этой страницей


Rubukkit - свой сервер Minecraft

Здравствуйте! При попытке запустить это чудо в WSL возникает ошибка.
app.sh: 5: Syntax error: word unexpected (expecting «do»)
mmDPdGnqfFo.jpg?size=875x310&quality=96&sign=3ca38911cfaa5a296107c24492ea63ce&type=album

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

Undermine2k's user avatar

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

rici's user avatar

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

Michael Tomkins's user avatar

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's user avatar

Kusalananda

312k35 gold badges614 silver badges909 bronze badges

asked Apr 26, 2018 at 12:56

Aftab Naveed's user avatar

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's user avatar

KusalanandaKusalananda

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's user avatar

tachomi

7,2024 gold badges24 silver badges45 bronze badges

answered Apr 26, 2018 at 13:14

Santosh's user avatar

#!/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

Aguevara's user avatar

  • Home
  • Forum
  • The Ubuntu Forum Community
  • Ubuntu Official Flavours Support
  • New to Ubuntu
  • [ubuntu] Syntax error: word unexpected (expecting «do»)

  1. 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


  2. 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).


  3. 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


  4. 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.


  5. 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


  6. 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!


Bookmarks

Bookmarks


Posting Permissions

Понравилась статья? Поделить с друзьями:
  • Word under the street
  • Word under the sea
  • Word under make sentence
  • Word ultcool что это
  • Word ultcool пароль от архива