Converting the following batch script to Linux shell

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Converting the following batch script to Linux shell
# 1  
Old 11-15-2016
Converting the following batch script to Linux shell

I am currently migrating to ubuntu from my windows system. Now I am learing to convert all my batch scripts into linux shell. Although the common commands are more or less similar, but I found it difficult for the following set of commands in windows cmd:

Code:
	setlocal
	:PROMPT
	SET /P AREYOUSURE=USE Consensus Disorder Regions (Y) / User Selection (N):
	IF /I "%AREYOUSURE%" NEQ "Y" GOTO FINISH1

	echo			  Options:
	echo.
	echo		  	  1)	IUPRED(Long) + PONDR(VSL2b) + DisEMBL(REM465)
	echo.
	echo		  	  2)	IUPRED(Long) + PONDR(VSL2b) + DisEMBL(COILS)
	echo.
	echo		  	  3)	IUPRED(Long) + PONDR(VSL2b) + DisEMBL(HOTLOOPS)
	echo.
	echo		  	  4)	IUPRED(Short) + PONDR(VSL2b) + DisEMBL(REM465)
	echo.
	echo		  	  5)	IUPRED(Short) + PONDR(VSL2b) + DisEMBL(COILS)

	CHOICE /C 12345 /M "Enter your choice:"

	:: Note - list ERRORLEVELS in decreasing order

	IF ERRORLEVEL 5 GOTO choice5
	IF ERRORLEVEL 4 GOTO choice4
	IF ERRORLEVEL 3 GOTO choice3
	IF ERRORLEVEL 2 GOTO choice2
	IF ERRORLEVEL 1 GOTO choice1

	:choice1
	perl script.pl input1.txt >> Output1.txt
	GOTO End
	:choice2
	perl script.pl input2.txt >> Output2.txt
	GOTO End
	:choice3
	perl script.pl input3.txt >> Output3.txt
	GOTO End
	:choice4
	perl script.pl input4.txt >> Output4.txt
	GOTO End
	:choice5
	perl script.pl input5.txt >> Output5.txt
	
	:End


	:FINISH1
	endlocal
	....
	Next scripts..
	...

These commands first prints few options, takes user choice and execute one perl script according to user choice.
I notice a function called "setlocale" in linux, but I don't understand how to use that in the above problem.

I appreciate all advice and suggestion.

Thanks
# 2  
Old 11-15-2016
I don't think setlocale can do anything for your above problem; it sets all the locale dependent variables to reflect your country, language, monetary system, time format and more.
For a menu as indicated, you might want to dive into bash's select buitlin - if you are using bash, that is, which you failed to mention.
# 3  
Old 11-15-2016
Code:
#!/bin/bash

read -r -p "USE Consensus Disorder Regions (Y) / User Selection (N): " -n 1
echo ""

choice[1]="IUPRED(Long) + PONDR(VSL2b) + DisEMBL(REM465)"
choice[2]="IUPRED(Long) + PONDR(VSL2b) + DisEMBL(COILS)"
choice[3]="IUPRED(Long) + PONDR(VSL2b) + DisEMBL(HOTLOOPS)"
choice[4]="IUPRED(Short) + PONDR(VSL2b) + DisEMBL(REM465)"
choice[5]="IUPRED(Short) + PONDR(VSL2b) + DisEMBL(COILS)"

PS3="Enter choice #: "
if [[ $REPLY =~ ^[Yy]$ ]]
then
  select opt in "${choice[@]}"
  do
     case $opt in
        "") : ;;
        $opt) perl script.pl input$REPLY.txt >> Output$REPLY.txt ; break ;;
        *) : ;;
     esac
     :
  done
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Batch to shell script conversion

Hi All, I have a small tool which is currently configured in batch scripts only. But my need is to run it on Linux platform, so I have been trying to convert a batch script to shell script. below is the batch script: @echo off IF "%1"== "" GOTO ARGERR REM UPDATE THESE PROPERTIES TO... (2 Replies)
Discussion started by: sukhdip
2 Replies

2. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

3. Shell Programming and Scripting

Converting DOS Batch file to Shell Script

Hi, This is my DOS Batch file. @echo off echo "Program Name :" %0 rem echo "Next param :" %1 echo "Next param :" "Username/Password" echo "User Id :" %2 echo "User Name :" %3 echo "Request ID ... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

4. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

5. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

6. Shell Programming and Scripting

Change the Windows Batch script to UNIX shell script.

Hi, When I run the below script in UNIX it's throwing syntax errors. Actually it's a windows batch script. Could anyone change the below Windows Batch script to UNIX shell script... Script: REM :: File Name : Refresh_OTL.bat REM :: Parameters : %1 - Region REM :: : %2 - Cube Type REM ::... (5 Replies)
Discussion started by: tomailraj
5 Replies

7. Solaris

Batch converting documents

Here is the situation. We are a company that has been using a professional publishing system, the software is called "ProType". It runs on Solaris 2.4, however it is no longer supported and we are forced to move on to Adobe Indesign. We must convert all our documents (thousands) to InDesign format.... (4 Replies)
Discussion started by: Fred Goldman
4 Replies

8. Shell Programming and Scripting

Converting Shell script to Dos batch files

Hi friends! I am having some simple shell script files to build postgresql database and all. Now i want to convert those scripts to dos batch scripts(to run on windows XP/2000/NT) because there is no need of unix emulation for latest release of postgresql. Please somebody help me. (1 Reply)
Discussion started by: darwinkna
1 Replies

9. UNIX for Dummies Questions & Answers

batch command in a shell script

How do I execute a batch command from a script, which "waits" with the next command until the first one has finished? ======= A piece of my script looks like this: #!/bin/sh (...) # run a long batch job: ./run_calculation.sh # then rename resulting file: mv output.dat backup.dat (...) ... (7 Replies)
Discussion started by: ivvo
7 Replies

10. Linux

Passing variables to sql from batch shell in linux

Hi, I need to put this command in a batch shell. sqlplus -s user/password @test.sql and in the test.sql I have this command select * from pbempl where pebempl_id = $1; How I can pass the variable $1 from the batch shell??? Thanks (2 Replies)
Discussion started by: rama71
2 Replies
Login or Register to Ask a Question