Windows Batch to Bash


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Windows Batch to Bash
# 1  
Old 02-12-2019
Windows Batch to Bash

This line is called in a windows batch file and I need to call the same 3 jars with Parms in a bash script.

Code:
cd "D:\ACDRIP\JARS"
java -cp ".\RIPError.jar;.\RIP31.jar;.\RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050
pause

Any ideas how to do this in Bash?
# 2  
Old 02-12-2019
What have you tried so far? Note some changes, if you are running on WSL (like ubuntu for windows 10):

backslashes '\' have to be forward slashes '/'

The environment variables have to be set in bash so that java runtime libraries (correct one(s)) are in the right environment variables, and java itself is in the PATH variable.

Other than that the only "pause" call in UNIX is from C, not bash, and its semantics are not the same. So you will have to emulate pause, i.e., write a bash function called pause()
# 3  
Old 02-12-2019
add a #!/bin/sh at line 1

D: must be a valid *nix path like /java

Code:
sed -i 's/\\/\//g'  <script>

will do the rest.

then you will have something like:

Code:
#!/bin/sh
cd "/java/JARS" 
java -cp "./RIPError.jar;./RIP31.jar;./RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050 
read

don'f forget the
Code:
chmod +x <script>


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-12-2019 at 05:27 PM.. Reason: Added CODE tags.
# 4  
Old 02-12-2019
Quote:
Originally Posted by dodona
Code:
#!/bin/sh
cd "/java/JARS" 
java -cp "./RIPError.jar;./RIP31.jar;./RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050 
read

In addition to what dodona already said: avoid relative pathes in scripts! Sooner or later (and always at the least convenient moment) they tend to bite your behind. I would change the above to:


Code:
#!/bin/sh
fAppRoot="/java/JARS"

cd "$fAppRoot"       # maybe not necessary any more
java -cp "$fAppRoot/RIPError.jar;$fAppRoot/RIP31.jar;$fAppRoot/RIP31msg_en_US.jar" ResubmitErrors -Ahost -P185050 
read

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
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 bash conversion

Hi, I am just trying to convert the batch script to bash script and i am stuck at one point where I have the below code for /f "delims=" %%a in (a.txt) do ( for /f "tokens=1,2,3* delims==" %%i in ("%%a") do ( for /f "tokens=1,2,3* delims= " %%x in ("%%i") do ( if... (4 Replies)
Discussion started by: prasanna2166
4 Replies

2. Shell Programming and Scripting

Windows Batch script for Unix commands

I wish to create a folder on a unix server B from my windows box using windows batch script. Below is my windows batch script. @ ECHO OFF ::Enter your Directory name: echo Enter your Directory name: set /p mydir= plink user1@ServerA mkdir %mydir% At plink command i get logged... (7 Replies)
Discussion started by: mohtashims
7 Replies

3. Windows & DOS: Issues & Discussions

How to start a vbs from a windows batch file?

Morning, I'm trying to execute a vbs from a .bat file. Can someone tell me what the difference is between these statements: start c:\lib\runit.vbc c:\lib\runit.vbs When I run the batch with the 'start' parameter it doesn't seem to do anything. (1 Reply)
Discussion started by: Grueben
1 Replies

4. Windows & DOS: Issues & Discussions

Gawk Script in Windows batch file - Help

Good morning all. I have been running into a problem running a simple gawk script that selects every third line from an input file and writes it to an output file. gawk "NR%3==0" FileIn > FileOut I am attempting to run this command from a batch file at the command line. I have several hundred... (6 Replies)
Discussion started by: 10000springs
6 Replies

5. Windows & DOS: Issues & Discussions

Check the file size using Batch script in windows

Hi, I need to check the file size using a batch script. Pls advise. (0 Replies)
Discussion started by: krackjack
0 Replies

6. Shell Programming and Scripting

Executing Windows batch file from UNIX

Hi everyone, let me get straight to the points. My manager wants to execute a remote batch file (on a Windows server) from a UNIX Machine, does anyone know if this is possible and what packages would be needed? Thanks p.s. Sorry i cant give OS specifics, we use most UNIX's; AIX, Solaris,... (5 Replies)
Discussion started by: flip387
5 Replies

7. Windows & DOS: Issues & Discussions

Windows services for unix - How do I run in batch

I just installed Windows Services for Unix. I want to create a ksh program and schedule it using the Windows scheduler. How would I go about doing it? What would the command line look like? Do I always have to be in a ksh shell to run the batch program even if it is not scheduled? ... (3 Replies)
Discussion started by: rbdenham
3 Replies

8. UNIX for Dummies Questions & Answers

backup through batch file in windows

Hi, I would like to backup particular files from unix to windows for every day through ftp to my desktop. For that anyone tell me syntax for create batch file in windows. Regards, Arulkumar (0 Replies)
Discussion started by: arulkumar
0 Replies

9. Windows & DOS: Issues & Discussions

windows scripting for a batch job

I have been doing unix scripting for quite awhile and there seems to be a wealth of information on it. Now I am working on migrating an intel based application to a new server. I need to modify some existing scripts, but am having trouble finding information on windows scripting, a forum similar... (2 Replies)
Discussion started by: MizzGail
2 Replies

10. UNIX for Dummies Questions & Answers

How can I run scripts in my unix account from batch file in Windows?

Hi all, I'm working on Windows, connecting to my Unix account by different ways: by FTP opening files in UltraEdit32, by mapping drive to browse, by Exceed or Telnet to compile at Unix account. Actually, that is what I would like to change: I'd like to make a batch file which would connect to... (7 Replies)
Discussion started by: olgafb
7 Replies
Login or Register to Ask a Question