bat to shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bat to shell
# 1  
Old 03-24-2012
Question bat to shell

I have serverfiles of same game. and there are bat files. I wont to run this on debian.
The files are difficult, eg
PHP Code:
:######################################################################## 
:# File name: server_start.bat
:# Edited Last By: Mike Gleaves (ric) 
:# V 1.0 1-10-2008
:# Comment: Run multi-Apache servers on same PC. Apache 2.2.9 core
:# modified by Novo (c)2010
:######################################################################## 

@echo off
color 3

rem 
## Save return path
pushd %~dp0

rem 
## Check to see if already stopped
if NOT exist AIONEmulator\usr\local\apache2\logs\httpd.pid goto :NOTSTARTED

rem 
## It exists is it running
SET /P pid=<AIONEmulator\usr\local\apache2\logs\httpd.pid
netstat 
-anop tcp FIND /" %pid%" 2>nul
IF ERRORLEVEL 1 goto :NOTRUNNING
IF ERRORLEVEL 0 goto :RUNNING

:NOTRUNNING
rem 
## Not shutdown using server_stop.bat hence delete file
del AIONEmulator\usr\local\apache2\logs\httpd.pid 2>nul
del AIONEmulator
\usr\local\mysql\data\mysql.pid 2>nul

:NOTSTARTED
set pass1
=found
set pass2
=found
rem 
## Check for another server on this Apache port
netstat -anp tcp FIND /"0.0.0.0:8096" 2>nul
IF ERRORLEVEL 1 set pass1=notfound

rem 
## Check for another server on this MySQL port
netstat -anp tcp FIND /"0.0.0.0:3316" 2>nul
IF ERRORLEVEL 1 set pass2=notfound

if %pass1%==notfound if %pass2%==notfound goto NOTFOUND
echo.
echo  
Both ports need to be free in order to run the servers
if %pass1%==notfound echo  Port 8096 is free OK to run Apache server
if %pass1%==found echo  Another server is running on port 8096 cannot run Apache server
if %pass2%==notfound echo  Port 3316 is free OK to run MySQL server
if %pass2%==found echo  Another server is running on port 3316 cannot run MySQL server
echo.
goto 
END

:NOTFOUND
echo  Port 8096 is free OK to run server
echo  Port 3316 is free OK to run server
rem 
## Find first free drive letter
rem ## Find first free drive letter
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do CD %%a1>> nul 2>&& if errorlevel 1 set freedrive=%%a

rem 
## Use batch file drive parameter if included else use freedrive
set Disk=%1
if "%Disk%"=="" set Disk=%freedrive%

rem ## To force a drive letter, remove "rem" and change drive leter
rem set Disk=w

rem 
## Having decided which drive letter to use create the disk
subst %Disk%: "AIONEmulator"

rem ## Save drive letter to file. Used by stop bat 
(set /p dummy=%Disk%) >AIONEmulator\usr\local\apache2\logs\drive.txt <nul

rem 
## Set variable paths
set apachepath=\usr\local\apache2\
set apacheit=%Disk%:%apachepath%bin\Apache_16.exe -%apachepath%conf\httpd.conf -%apachepath%.

rem ## Start Apache server
%Disk%:
start %Disk%:\home\admin\program\uniserv.exe "%apacheit%" 

rem ## Start MySQL server
start /MIN \usr\local\mysql\bin\mysqld-opt.exe --defaults-file=/usr/local/mysql/my.cnf

rem 
### Wait for Apache to start
echo  Apache starting ....
:
next
home
\admin\program\unidelay.exe
if NOT exist usr\local\apache2\logs\httpd.pid goto :next

rem 
### Wait for MySQL to start
echo  MySQL starting ....
:
next2
home
\admin\program\unidelay.exe
if NOT exist usr\local\mysql\data\mysql.pid goto :next2


echo.
echo  
The Apache server is working on disk %Disk%:\ [http/127.0.0.1]
echo.
echo  
To open site type http://localhost:8096 into a browser
echo.
echo  
The MySQL server is working on disk %Disk%:\ [port 3316]

echo.
echo  
Checking for corruptnot cleanly closed and upgrade needing MySQL tables ...
if 
exist \usr\local\mysql\bin\mysqlcheck.exe call \usr\local\mysql\bin\mysqlcheck.exe --defaults-file=/usr/local/mysql/my.cnf --user=root --password=aion --all-databases --silent --force --check --auto-repair --use-frm
echo.

goto :
END

:RUNNING
CLS
echo.
echo  
This Apache server is already running.
echo  
You can stop the server using server_stop.bat

:END
echo.
rem pause

rem 
## Return to caller
popd 
How can I convert bat to shell, or maybe how can I run bat files on debian?

Have you any ideas?
# 2  
Old 03-24-2012
Hi, have you googled for bat2sh, bat2ksh or bat2bash?
# 3  
Old 03-24-2012
Yes, but haven't found anything special
# 4  
Old 03-24-2012
You are right there does not appear to be much out there. I guess that the structures and concepts are rather different and that anything other than symbol translations may be challenging..

If I look at you script is appears to be a wrapper script around apache. I think a better approach may be to use the standard /etc/init.d/apache2 or /etc/init.d/httpd script or similar on your system and take it from there...
# 5  
Old 03-25-2012
Thanks, I will try. Or mayby someone else has an idea?
# 6  
Old 03-25-2012
Hi.

I would say that one is better off looking at such problems from a new perspective rather than trying to convert command-for-command

However, there is a table of batch-to-shell equivalents at Converting DOS Batch Files to Shell Scripts for help with translation, porting, etc.

Best wishes ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Convert .sh to .bat please

Can someone translate this code to .bat for me? I have no clue. #!/bin/sh WAS_HOME="/opt/websphere/appserver/profiles/AppSrv01" WAS_APP_SERVER="server1" WAS_PROFILE_NAME="AppSrv01" echo "Stopping App Server" "${WAS_HOME}/bin/stopServer.sh" -profileName $WAS_PROFILE_NAME $WAS_APP_SERVER... (1 Reply)
Discussion started by: Blogger11
1 Replies

2. Shell Programming and Scripting

BAT to SH help

First off, let me apologize if I'm posting this in the wrong place! I am a newbie to this forum, to shell scripting and to Linux so please bare with me. I created a script on the windows environment that makes a call to a java application and extracts a return value from the java app. It... (7 Replies)
Discussion started by: arod291
7 Replies

3. Shell Programming and Scripting

Need help with bat file!!!

I need to put/get files from Windows machine to Unix machine and vice-versa. I wrote a text file "ftp1.txt" as below. naga naga06 cd /root/Naga prom off get time.unl bye I wrote another bat file "ftp.bat" as below. ftp -n -s:C:\Users\Naga\Desktop\ftp1.txt IP_ADDRESS but... (2 Replies)
Discussion started by: Naga06
2 Replies

4. Windows & DOS: Issues & Discussions

Executing .bat file

Hi , I have a bat file on windows machine ,I need to excute it from my local unix machine using sambe utility.Is there any comman to execute the .bat file remotely. Using samba utility i can post files to and fro from windows to unix but i don't comman to exute the .bat file. can any one... (2 Replies)
Discussion started by: Raamc
2 Replies

5. Windows & DOS: Issues & Discussions

.bat script help

hi I need to rediret an content of one file and append it to another file. I need it in .bat script. I tried this, first.txt I love to write script type first.txt >> out.txt type first.txt >> out.txt out.txt I love to write scriptI love to write script you see the... (6 Replies)
Discussion started by: ilugopal
6 Replies

6. Shell Programming and Scripting

.bat or .pl script help

hi I need to rediret an content of one file and append it to another file. I need it in .bat script. I tried this, first.txt I love to write script type first.txt >> out.txt type first.txt >> out.txt out.txt I love to write scriptI love to write script you see the second... (1 Reply)
Discussion started by: ilugopal
1 Replies

7. Shell Programming and Scripting

Writing Bash shell scripts corresponding to windows bat files

Experts, I am newbie in shell scripting. I want to write Bash shell scripts corresponding to windows bat files. I have installed cygwin at c:\cygwin and i am trying to crate the sh file using vi editor. i am not able to understand how to use linux/unix convention for the code. following is my... (15 Replies)
Discussion started by: rajuchacha007
15 Replies

8. Shell Programming and Scripting

Create Bash shell scripts corresponding to windows bat files

Experts, I am newbie in shell scripting. I want to write Bash shell scripts corresponding to windows bat files. I have installed cygwin at c:\cygwin and i am trying to crate the sh file using vi editor. i am not able to understand how to use linux/unix convention for the code. following is my... (1 Reply)
Discussion started by: rajuchacha007
1 Replies

9. Shell Programming and Scripting

Simple bat file

Hi guys, I need a *.bat to run a ksh file in the shell on Windows NT...nothing more :) How do I do it? I tried with the following but it failed: set INFORMIXDIR=D:\user-applications\informix set PATH=%INFORMIXDIR%;%PATH% D:\user-applications\MKS\mksnt\sh.exe C:\hk_9.2\C3_weekly_auto.ksh... (4 Replies)
Discussion started by: Dird
4 Replies

10. Shell Programming and Scripting

Run shell script from .bat file

hi how can I execute a shell script on unix server from a .bat file of windows desktop?? Regards. (3 Replies)
Discussion started by: Chaitrali
3 Replies
Login or Register to Ask a Question