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: Code:
@echo off launch.cmd <config-file> the above batch is saved in launch.cmd file. Below is my effort to convert it into shell. Code:
#!/bin/bash This is half done as I was in the process to convert step by step. But getting the below error for jar files configurations. Code:
./new.sh: line 20: /opt/BART$BART_VERlibcommons-configuration-1.6.jar: No such file or directory Plus I'm struggling to understand and convert the below line. Code:
:ARGERR Thanks In Advance... |
Change the
Quote:
Quote:
Quote:
|
Quote:
But back to the script that @sukhdip presented. GOTOS are not used in shell scripts. First of all, you should try to note these commands as part of control-structures. You could use a switch-case statement but in your script simple if-else forks will do nicely. The GOTO problem will evaporate. Where you just need to print a message, then exit, use the exit command. The bash has a nice man page (man bash) and if you search and concentrate just on your specific points of interest, it is not too impressive. Control structures are found in the section about “Compound Commands”. |
Thanks guys!!! Silly mistake by me...didn't even get a chance to see that!!
@Michael Uplawski appreciate your effort to explain it. |
Also, its generally a good idea to make it explicit to the parser when you've got embedded vars ie vars in the middle of a string eg
Code:
export BART_LIB_DIR=$BART_HOME\$BART_VER\lib Some good links: http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ |
Further, a semicolom means the end of a shell command.
It needs to be \escaped or within "quotes" if part of a string. Code:
export COMMONS_LIB="$BART_LIB_dir/commons-collections-3.2.1.jar;$BART_LIB_DIR/commons-configuration-1.6.jar;$BART_LIB_DIR/commons-lang-2.4.jar;$BART_LIB_DIR/commons-logging-1.1.1.jar;$BART_LIB_DIR/commons-io-1.4.jar;$BART_LIB_DIR/xmlunit-1.2.jar" |
All times are GMT -5. The time now is 06:26 PM. |