Results 1 to 10 of 10
Hi guys, can someone help me convert this dos script to sl??
Code:
echo off
cls
:start
echo.
ECHO Manutencao de BD
ECHO - - - - - - - ...
- 09-22-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 19
shell script
Hi guys, can someone help me convert this dos script to sl??
thanksCode:echo off cls :start echo. ECHO Manutencao de BD ECHO - - - - - - - - - - ECHO Backup ECHO 1. Backup Diario ECHO 2. Backup Semanal ECHO 3. Backup Mensal ECHO - - - - - - - - - - ECHO Restauro ECHO 4. Restauro Diario ECHO 5. Restauro Semanal ECHO 6. Restauro Mensal ECHO - - - - - - - - - - ECHO 7. Sair echo. echo. set /p x=Escolha uma opcao:_ IF '%x%'== '7' exit set /p t=Tem a certeza?(s/n) IF '%t%' == 's' GOTO Item_%x% GOTO Start :Item_1 cd/ cd Program Files/PostgreSQL/8.4/bin pg_dump.exe --host localhost --port 5432 --username postgres --format custom --blobs --verbose --file "C:\Users\Ricardo\Desktop\Backup\db\diario\dumpDB_openclinica_diario.backup" openclinica cd/ cd Users\Ricardo\Desktop\Backup\DB\diario copy *.* e: echo. ECHO Backup Diario Efectuado com sucesso echo. GOTO Start :Item_2 cd/ cd Program Files/PostgreSQL/8.4/bin pg_dump.exe --host localhost --port 5432 --username postgres --format custom --blobs --verbose --file "C:\Users\Ricardo\Desktop\Backup\db\semanal\dumpDB_openclinica_semanal.backup" openclinica cd/ cd Users\Ricardo\Desktop\Backup\DB\semanal copy *.* e: echo. ECHO Backup Semanal Efectuado com sucesso echo. GOTO Start :Item_3 cd/ cd Program Files/PostgreSQL/8.4/bin pg_dump.exe --host localhost --port 5432 --username postgres --format custom --blobs --verbose --file "C:\Users\Ricardo\Desktop\Backup\db\mensal\dumpDB_openclinica_mensal.backup" openclinica cd/ cd Users\Ricardo\Desktop\Backup\DB\mensal copy *.* e: echo. ECHO Backup Mensal Efectuado com sucesso echo. GOTO Start :Item_4 cd/ cd Program Files/PostgreSQL/8.4/bin pg_restore.exe --host localhost --port 5432 --username postgres --dbname openclinica --list "C:\Users\Ricardo\Desktop\Backup\DB\diario\dumpDB_openclinica_diario.backup" echo. ECHO Restauro Diario Efectuado com sucesso echo. GOTO Start :Item_5 cd/ cd Program Files/PostgreSQL/8.4/bin pg_restore.exe --host localhost --port 5432 --username postgres --dbname openclinica --list "C:\Users\Ricardo\Desktop\Backup\DB\semanal\dumpDB_openclinica_semanal.backup" echo. ECHO Restauro Semanal Efectuado com sucesso echo. GOTO Start :Item_6 cd/ cd Program Files/PostgreSQL/8.4/bin pg_restore.exe --host localhost --port 5432 --username postgres --dbname openclinica --list "C:\Users\Ricardo\Desktop\Backup\DB\mensal\dumpDB_openclinica_mensal.backup" echo. ECHO Restauro Mensal Efectuado com sucesso echo. GOTO Start
- 09-23-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
There are a number of online texts for learning bash that will help you with this. The ECHO statements will work unchanged if you change them to lower case echo. Anyway, check this out: The Linux Documentation Project: Guides
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 09-23-2011 #3Just Joined!
- Join Date
- Sep 2011
- Posts
- 19
thanks, ill see what i can do
- 09-23-2011 #4Just Joined!
- Join Date
- Sep 2011
- Posts
- 19
Would it be something like this??
But i still dont seem to find a way to add a are you right? (y/n) optionCode:#!/bin/bash selection= until [ "$selection" = "0" ]; do echo "" echo Manutencao de BD echo - - - - - - - - - - echo Backup echo 1. Backup Diario echo 2. Backup Semanal echo 3. Backup Mensal echo - - - - - - - - - - echo Restauro echo 4. Restauro Diario echo 5. Restauro Semanal echo 6. Restauro Mensal echo - - - - - - - - - - echo 7. Sair echo "" echo -n "Escolha uma opcao: " read selection echo "" case $selection in 1 ) xpto ;; 2 ) xpto ;; 3 ) xpto ;; 4 ) xpto ;; 5 ) xpto ;; 6 ) xpto ;; 7 ) exit ;; * ) echo "Escolha uma das opções apresentadas no menu" esac done
- 09-23-2011 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
You can add another read statement to get that answer, and process it with an if/fi block, only going to the case statements if the answer is "y" or "Y".
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 09-23-2011 #6Just Joined!
- Join Date
- Sep 2011
- Posts
- 19
like this??
Code:#!/bin/bash selection= until [ "$selection" = "0" ]; do echo "" echo Manutencao de BD echo - - - - - - - - - - echo Backup echo 1. Backup Diario echo 2. Backup Semanal echo 3. Backup Mensal echo - - - - - - - - - - echo Restauro echo 4. Restauro Diario echo 5. Restauro Semanal echo 6. Restauro Mensal echo - - - - - - - - - - echo 7. Sair echo "" echo -n "Escolha uma opcao: " read selection echo "" echo -n "Tem a certeza?(s/n) " read text if [ $text= "s" ]; then case $selection in 1 ) xpto ;; 2 ) xpto ;; 3 ) xpto ;; 4 ) xpto ;; 5 ) xpto ;; 6 ) xpto ;; 7 ) exit ;; * ) echo "Escolha uma das opções apresentadas no menu" esac else fi done
- 09-23-2011 #7Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Basically, yes although you can leave out the 'else' unless you want to do something in the else branch, such as outputting "cancelled". One final suggestion is to put in the test for "s", a test for "S" as well just in case the user used caps.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 09-23-2011 #8Just Joined!
- Join Date
- Sep 2011
- Posts
- 19
you mean like this??
if [ $text= "s" or $text= "S" ]; then
or like this?
if [ $text= "s" ] or [ $text= "S" ]; then
or non of the above? :SLast edited by razstec; 09-23-2011 at 04:22 PM.
- 09-23-2011 #9Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Try
if [ $text= "s" ] || [ $text= "S" ]; then
or
if [ $text= "s" || $text= "S" ]; then
You might find the bash man page helpful. Execute the command man bash from the command line.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 09-26-2011 #10Just Joined!
- Join Date
- Sep 2011
- Posts
- 19
thanks

Ill test it soon


Reply With Quote