Slax-скрипт не фурычит

Дистрибутивы, не требующие установки на диск.

Модератор: Модераторы разделов

Lamaka
Сообщения: 2
ОС: BT3Final USB

Slax-скрипт не фурычит

Сообщение Lamaka »

Копипастю нижеследующий скрипт,сохраняю.Запускаю в консоли,где он-save_changes.sh,а мне в ответ-

./save_changes.sh: line34: syntax error near unexpected token 'fi'

./save_changes.sh: line34: 'fi'
Чую,что косяк в области "в какой кодировке был предварительно сохранен текстовый формат скрипта".Есть у кого какие-нибудь соображения?


Код: Выделить всё

#Created by Ferg (www.FergSoft.com)

#Saves all changes made to BT3

#when booting from a USB drive.

#Can also merge existing files.

#Version 2.00

save_merge() {

clear

echo -e ”\n\033[1;36mSaving changes...\033[1;34m"

dir2lzm /root/savetmp $drv/BT3/modules/$fl

rm -r /root/savetmp

echo -e -n "\033[0m\nFinished merging files. Press 'enter' to exit.";read

clear

exit 0

}

select_files(){

echo -e "\n\033[0m Enter the name of a file to merge"

echo -n " or type 'done' to begin merging the files: ";read fln

fltest=${fln#*.}

if [ "$fltest" == "lzm" ]

then

fltmp=”$fln”

else

fltmp=”$fln.lzm”

fi

if [ "$fln" == "done" ]

then

name_file

fi

if [ ! -e $drv/BT3/modules/$fltmp ]

then

echo -e ”\033[1;31m\n-----------------ERROR------------------"

echo "File could not be found! ($fltmp) Check the name and try again."

echo -e -n "\n\033[0mPress 'enter' to return.";read

select_files

fi

lzm2dir $drv/BT3/modules/$fltmp /root/savetmp &> /dev/null

echo -e "\033[1;32m\n Added $fltmp.\033[0m"

select_files

clear

}

name_file(){

clear

echo -e "\033[1;32m\nExisting Files Found:\n\033[1;36m"

ls $drv/BT3/modules | grep .lzm

echo -e "\033[1;31m\n WARNING: If you overwrite a file,"

echo -e " the changes in the old file will be lost.\n\033[0m"

echo -n -e " Enter a new filename: ";read fln

clear

fltest=${fln#*.}

if [ "$fltest" == "lzm" ]

then

fl=”$fln”

else

fl=”$fln.lzm”

fi

save_merge

}

#————————————–

select_drive (){

guess=”none”

num=1

until [ $num == 10 ]

do

if [ -d "/mnt/sdb$num/BT3/modules" ]

then

guess=”/mnt/sdb$num”

fi

if [ -d "/mnt/sda$num/BT3/modules" ]

then

guess=”/mnt/sda$num”

fi

if [ -d "/mnt/sdc$num/BT3/modules" ]

then

guess=”/mnt/sdc$num”

fi

if [ -d "/mnt/sdd$num/BT3/modules" ]

then

guess=”/mnt/sdd$num”

fi

let num=num+1

done

if [ "$guess" == "none" ]

then

echo -e ”\033[1;32m\nDrives Found:\n\033[1;36m"

mount | grep vfat

mount | grep fuseblk

echo -e "\033[0m\n Enter the path to the drive containing your BT3/modules folder."

echo -n " (Default: /mnt/sdb1): ";read drv

if [ "$drv" == "" ]

then

drv=”/mnt/sdb1″

fi

else

echo -e -n ”\nFound \033[1;32m$guess\033[0m. Is this the correct path to your BT3 drive? (y/n): ";read yn

if [ "$yn" == "y" -o "$yn" == "" ]

then

drv=”$guess”

else

echo -e ”\033[1;32m\nDrives Found:\n\033[1;36m"

mount | grep vfat

mount | grep fuseblk

echo -e "\033[0m\n Enter the path to the drive containing your BT3/modules folder."

echo -n " (Default: /mnt/sdb1): ";read drv

if [ "$drv" == "" ]

then

drv=”/mnt/sdb1″

fi

fi

fi

clear

if [ ! -e $drv/BT3/modules ]

then

echo -e ”\033[1;31m\n-----------------ERROR------------------"

echo " Directory doesn't exist: $drv/BT3/modules"

echo " check the drive and try again."

echo -e -n "\033[0m\nPress 'enter' to continue.";read

clear

select_drive

fi

}

#--------------------------------------

save_file() {

clear

echo -e "\n\033[1;36mSaving changes...\033[1;34m"

dir2lzm /mnt/live/memory/changes $drv/BT3/modules/$fl

echo -e -n "\033[0m\nFinished saving file. Press 'enter' to exit.";read

exit 0

}

select_file () {

echo -e "\033[1;32m\nExisting Files Found:\n\033[1;36m"

ls $drv/BT3/modules | grep .lzm

echo -e "\033[1;31m\n WARNING: If you overwrite a file,"

echo -e " the changes in the old file will be lost.\n\033[0m"

echo -n -e " Enter a new filename: ";read fln

clear

fltest=${fln#*.}

if [ "$fltest" == "lzm" ]

then

fl=”$fln”

else

fl=”$fln.lzm”

fi

save_file

}

#————————————–

main_menu(){

clear

echo -e ”\033[1;36m\nPlease choose an option:\n\033[0m"

echo " n - New changes file"

echo " m - Merge files"

echo " h - Help"

echo -e "\n q - Quit"

echo -e -n "\n Choice (Default: 'n'): ";read sel

clear

if [ "$sel" == "" ]

then

sel=”n”

fi

if [ "$sel" == "n" ]

then

select_drive

select_file

fi

if [ "$sel" == "m" ]

then

if [ -d /root/savetmp ]

then

rm -r /root/savetmp

fi

mkdir /root/savetmp

select_drive

echo -e ”\033[1;32m\nExisting Files Found:\n\033[1;36m"

ls $drv/BT3/modules | grep .lzm

select_files

fi

if [ "$sel" == "h" ]

then

echo -e ”\n Changes are stored in the directory \033[1;32m/mnt/live/memory/changes\033[0m."

echo " This is temporary space that will be empty at every boot of"

echo " BackTrack 3. In order to save these changes, you must save the"

echo " directory into a lzm file. This file will then have to be in "

echo -e " the \033[1;32m/mnt/<dirve>/BT3/modules\033[0m directory at boot time to be loaded."

echo " If you save changes during one session, then overwrite the changes"

echo " file during a new session, none of the changes from the first "

echo " session will be saved. Therefore you have to either merge the "

echo " existing changes file with the new one or save the new changes "

echo -e " as a different filename.\n\033[0m"

echo " To convert a directory to an lzm file this script uses the"

echo -e " program \033[1;32mdir2lzm\033[0m. Below is the help file info."

dir2lzm --help

echo -n -e "\nPress 'enter' to continue...";read

main_menu

fi

if [ "$sel" == "q" ]

then

exit 0

fi

}

#————————————–

clear

echo -e ”\033[1;36m\n Use this to save all changes made during”

echo ” this session. This includes any files”

echo ” created or added to the filesystem, so”

echo ” it is a good idea to store large files”

echo -e ” in the root of the thumb drive.\n”

echo -e -n ”\033[0mPress ‘enter’ to continue.”;read

main_menu

clear

echo -e ”\n You must enter a valid choice!\n\nProgram will now exit.”;read
Спасибо сказали:
Аватара пользователя
ormorph
Сообщения: 2477
ОС: Gentoo

Re: Slax-скрипт не фурычит

Сообщение ormorph »

Хм интересно почему вообще этот скрипт работать должен?
Обратите внимание на кавычки например строка:

Код: Выделить всё

echo -e “\033[1;36m\nPlease choose an option:\n\033[0m"

# А должно быть

echo -e "\033[1;36m\nPlease choose an option:\n\033[0m"


кавычки в начале и в конце должны быть одни и теже и такое много где в скрипте, не говоря уже что кавычки кавычкам рознь, т.е. разное назначение.
Возьмите нормальный редактор с подсветкой синтаксиса и правьте. а потом уже проверяйте работо-способность
Спасибо сказали:
Lamaka
Сообщения: 2
ОС: BT3Final USB

Re: Slax-скрипт не фурычит

Сообщение Lamaka »

Друг,я же не программер.Подсоби?Может сможешь сварганить из этого кода сейв-скрипт?Суть его должна была,по заверению автора,при наборе в консоле,где находится скрипт,...save_changes.sh сохранять и подгружать при загрузке все сохранения?Поможешь?
Спасибо сказали:
Аватара пользователя
ormorph
Сообщения: 2477
ОС: Gentoo

Re: Slax-скрипт не фурычит

Сообщение ormorph »

Ну здесь не обязательно прогером быть, тем более что подсказка сделана, "все сводилось к правильной растановке кавычек"

Вот рабочий код:

Код: Выделить всё

#!/bin/bash

#Created by Ferg (www.FergSoft.com)
#Saves all changes made to BT3
#when booting from a USB drive.
#Can also merge existing files.
#Version 2.00

save_merge() {
    clear
    echo -e "\n\033[1;36mSaving changes...\033[1;34m"
    dir2lzm /root/savetmp $drv/BT3/modules/$fl
    rm -r /root/savetmp
    echo -e -n "\033[0m\nFinished merging files. Press 'enter' to exit.";read
    clear
    exit 0
}

select_files(){
    echo -e "\n\033[0m Enter the name of a file to merge"
    echo -n " or type 'done' to begin merging the files: ";read fln
    fltest=${fln#*.}
    if [ "$fltest" == "lzm" ]
    then
    fltmp="$fln"
    else
    fltmp="$fln.lzm"
    fi
    if [ "$fln" == "done" ]
    then
    name_file
    fi
    if [ ! -e $drv/BT3/modules/$fltmp ]
    then
    echo -e "\033[1;31m\n-----------------ERROR------------------"
    echo "File could not be found! ($fltmp) Check the name and try again."
    echo -e -n "\n\033[0mPress 'enter' to return.";read
    select_files
    fi
    lzm2dir $drv/BT3/modules/$fltmp /root/savetmp &> /dev/null
    echo -e "\033[1;32m\n Added $fltmp.\033[0m"
    select_files
    clear
}

name_file(){
    clear
    echo -e "\033[1;32m\nExisting Files Found:\n\033[1;36m"
    ls $drv/BT3/modules | grep .lzm
    echo -e "\033[1;31m\n WARNING: If you overwrite a file,"
    echo -e " the changes in the old file will be lost.\n\033[0m"
    echo -n -e " Enter a new filename: ";read fln
    clear
    fltest=${fln#*.}
    if [ "$fltest" == "lzm" ]
    then
    fl="$fln"
    else
    fl="$fln.lzm"
    fi
    save_merge
}

#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013

select_drive (){
    guess="none"
    num=1
    until [ $num == 10 ]
    do
    if [ -d "/mnt/sdb$num/BT3/modules" ]
    then
    guess="/mnt/sdb$num"
    fi
    if [ -d "/mnt/sda$num/BT3/modules" ]
    then
    guess="/mnt/sda$num"
    fi
    if [ -d "/mnt/sdc$num/BT3/modules" ]
    then
    guess="/mnt/sdc$num"
    fi
    if [ -d "/mnt/sdd$num/BT3/modules" ]
    then
    guess="/mnt/sdd$num"
    fi
    let num=num+1
    done
    if [ "$guess" == "none" ]
    then
    echo -e "\033[1;32m\nDrives Found:\n\033[1;36m"
    mount | grep vfat
    mount | grep fuseblk
    echo -e "\033[0m\n Enter the path to the drive containing your BT3/modules folder."
    echo -n " (Default: /mnt/sdb1): ";read drv
    if [ "$drv" == "" ]
    then
    drv="/mnt/sdb1"
    fi
    else
    echo -e -n "\nFound \033[1;32m$guess\033[0m. Is this the correct path to your BT3 drive? (y/n): ";read yn
    if [ "$yn" == "y" -o "$yn" == "" ]
    then
    drv="$guess"
    else
    echo -e "\033[1;32m\nDrives Found:\n\033[1;36m"
    mount | grep vfat
    mount | grep fuseblk
    echo -e "\033[0m\n Enter the path to the drive containing your BT3/modules folder."
    echo -n " (Default: /mnt/sdb1): ";read drv
    if [ "$drv" == "" ]
    then
    drv="/mnt/sdb1"
    fi
    fi
    fi
    clear
    if [ ! -e $drv/BT3/modules ]
    then
    echo -e "\033[1;31m\n-----------------ERROR------------------"
    echo " Directory doesn't exist: $drv/BT3/modules"
    echo " check the drive and try again."
    echo -e -n "\033[0m\nPress 'enter' to continue.";read
    clear
    select_drive
    fi
}

#--------------------------------------

save_file() {

    clear
    echo -e "\n\033[1;36mSaving changes...\033[1;34m"
    dir2lzm /mnt/live/memory/changes $drv/BT3/modules/$fl
    echo -e -n "\033[0m\nFinished saving file. Press 'enter' to exit.";read
    exit 0
}

select_file () {

    echo -e "\033[1;32m\nExisting Files Found:\n\033[1;36m"
    ls $drv/BT3/modules | grep .lzm
    echo -e "\033[1;31m\n WARNING: If you overwrite a file,"
    echo -e " the changes in the old file will be lost.\n\033[0m"
    echo -n -e " Enter a new filename: ";read fln
    clear
    fltest=${fln#*.}
    if [ "$fltest" == "lzm" ]
    then
    fl="$fln"
    else
    fl="$fln.lzm"
    fi
    save_file
}

#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013

main_menu(){

    clear
    echo -e "\033[1;36m\nPlease choose an option:\n\033[0m"
    echo " n - New changes file"
    echo " m - Merge files"
    echo " h - Help"
    echo -e "\n q - Quit"
    echo -e -n "\n Choice (Default: 'n'): ";read sel
    clear
    if [ "$sel" == "" ]
    then
    sel="n"
    fi
    if [ "$sel" == "n" ]
    then
    select_drive
    select_file
    fi
    if [ "$sel" == "m" ]
    then
    if [ -d /root/savetmp ]
    then
    rm -r /root/savetmp
    fi
    mkdir /root/savetmp
    select_drive
    echo -e "\033[1;32m\nExisting Files Found:\n\033[1;36m"
    ls $drv/BT3/modules | grep .lzm
    select_files
    fi
    if [ "$sel" == "h" ]
    then
    echo -e "\n Changes are stored in the directory \033[1;32m/mnt/live/memory/changes\033[0m."
    echo " This is temporary space that will be empty at every boot of"
    echo " BackTrack 3. In order to save these changes, you must save the"
    echo " directory into a lzm file. This file will then have to be in "
    echo -e " the \033[1;32m/mnt/<dirve>/BT3/modules\033[0m directory at boot time to be loaded."
    echo " If you save changes during one session, then overwrite the changes"
    echo " file during a new session, none of the changes from the first "
    echo " session will be saved. Therefore you have to either merge the "
    echo " existing changes file with the new one or save the new changes "
    echo -e " as a different filename.\n\033[0m"
    echo " To convert a directory to an lzm file this script uses the"
    echo -e " program \033[1;32mdir2lzm\033[0m. Below is the help file info."
    echo "dir2lzm --help"
    echo -n -e "\nPress 'enter' to continue...";read
    main_menu
    fi
    if [ "$sel" == "q" ]
    then
    exit 0
    fi
}

#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013

clear
echo -e "\033[1;36m\n Use this to save all changes made during"
echo " this session. This includes any files"
echo " created or added to the filesystem, so"
echo " it is a good idea to store large files"
echo -e " in the root of the thumb drive.\n"
echo -e -n "\033[0mPress \u2018enter\u2019 to continue.";read
main_menu
clear
echo -e "\n You must enter a valid choice!\n\nProgram will now exit.";read


Проверял работает в полне нормально.
Преднозначен для backtrack-3
Спасибо сказали:
Alsarine
Сообщения: 200
ОС: PCLinuxOS LXDE 2010.12 desktop

Re: Slax-скрипт не фурычит

Сообщение Alsarine »

Не пойму в чем дело,поставил slax на флешку 4Gb,при запуске скрипта загрузчика в терминале выдает что то,быстро закрывается терминал,прочитал только fatal error,флешку форматировал,что только не делал,не пойму.
Спасибо сказали:
Аватара пользователя
ormorph
Сообщения: 2477
ОС: Gentoo

Re: Slax-скрипт не фурычит

Сообщение ormorph »

Alsarine писал(а):
08.10.2009 12:59
Не пойму в чем дело,поставил slax на флешку 4Gb,при запуске скрипта загрузчика в терминале выдает что то,быстро закрывается терминал,прочитал только fatal error,флешку форматировал,что только не делал,не пойму.


Как ставили?
ну и что прописано в файле syslinux.cfg

вообще slax на флэхе не очень хорошо уживается, из за того что все время записывает изменения на флэху, при этом через некоторое время портит раздел флэхи, это обычно происходит если установлен в FAT.
То есть, не очень хорошо работает если установлен в FAT.
Спасибо сказали: