Converting .sh shellscript file to .bat batch file
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Aravind_P
Posted On:   Tuesday, October 10, 2006 03:29 AM

Hi All I need to convert a .sh file to .bat file in order to run the script in WINDOWS. I have a sample .sh file. ---------------------------------------------- #!/usr/bin/ksh # this script take a input param. if [ "$#" -eq "0" ]; then echo "please enter a log file name and path" else FileName="$1" if [ -e $FileName ]; then echo "Starting Time Stamp" head -n 1 $FileName | cut -b17-35 echo "End time Stamp" tail -n 1 $FileName | cut -b15-33 else echo " the file not found" fi fi ----------------------------------------------    More>>

Hi All

I need to convert a .sh file to .bat file in order to run the script in WINDOWS.
I have a sample .sh file.
----------------------------------------------
#!/usr/bin/ksh

# this script take a input param.

if [ "$#" -eq "0" ]; then
echo "please enter a log file name and path"
else

FileName="$1"
if [ -e $FileName ]; then
echo "Starting Time Stamp"
head -n 1 $FileName | cut -b17-35
echo "End time Stamp"
tail -n 1 $FileName | cut -b15-33
else
echo " the file not found"
fi
fi
----------------------------------------------


Can anyone please guide me how to write this script as a .bat file


Thanks in Advance
Aravind

   <<Less

Re: Converting .sh shellscript file to .bat batch file

Posted By:   Robert_Lybarger  
Posted On:   Saturday, October 21, 2006 11:14 PM

You could just start with "help" on the windows command line to see the batch script commands available (pay attention to 'set' and 'if') and you'd be okay up to the the head/cut and tail/cut command pipes, as I don't believe straight windows batch has anything synonymous for the UNIX-derived head, tail, or cut. The best choices, IMO, are to install cygwin to run the original script as is or to 'port' the bourne shell script into, say, Java (hey look, a java forum!) so it'll work on both systems.

Re: Converting .sh shellscript file to .bat batch file

Posted By:   Christopher_Koenigsberg  
Posted On:   Saturday, October 21, 2006 09:57 PM

You could install cygwin on the windows box, and then you could just run the sh script in the Bash shell, in a cygwin terminal window.
About | Sitemap | Contact