LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-14-2011, 08:20 PM   #1
noobquest
LQ Newbie
 
Registered: Jun 2011
Posts: 3

Rep: Reputation: Disabled
Converting a .bat into .sh


Hello, I'm completely new to linux never touched it until last night where I had to buy a host in linux through searching google and other forums I was able to get everything working until I had to convert my .bat into .sh to start my server. I tried many things and added the permissions to the files which is what I read you should do after converting. But the .sh does nothing when I try to run it with sh <filename>

linux: CentOS 5.5
and using PaTTy in SSL

this is the .bat
@java -Xmx512m -Xincgc -cp l1jserver.jar;lib\xmlapi;lib\c3p0-0.9.1.2.jar;lib\mysql-connector-java-5.1.7-bin.jar;lib\javolution.jar
@pause

This is the .sh which I did after reading some guides and forums
#!/bin/bash

# exit codes of GameServer:
# 0 normal shutdown
# 2 reboot attempt

while :; do
[ -f log/java0.log.0 ] && mv log/java0.log.0 "log/`date +%Y-%m-%d_%H-%M-%S`_java.log"
[ -f log/stdout.log ] && mv log/stdout.log "log/`date +%Y-%m-%d_%H-%M-%S`_stdout.log"
java -Xms1024m -Xmx1024m -cp l1jserver.jar:lib/c3p0-0.9.1.2.jar:lib/mysql-connector-java-5.1.7-bin.jar:lib/javolution.jar l1j.server.Server > log/stdout.log 2>&1
[ $? -ne 2 ] && break
# /etc/init.d/mysql restart
sleep 10
done


If anyone can tell me what I'm doing wrong that'll be very helpful

Thanks, Noobquest

Last edited by noobquest; 06-14-2011 at 08:22 PM.
 
Old 06-14-2011, 08:38 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Add
Code:
set -xv
as the 2nd line and run it again, but just using the filename eg
Code:
./yourfile.sh
Because you have
Code:
#!/bin/bash
at the top, you don't need to specify 'sh' on the cmd line.
Also. show us the output from
Code:
ls -l
so we can check the ownerships and permissions.

Here are some useful links
http://rute.2038bug.com/index.html.gz
http://linux.oneandoneis2.org/LNW.htm
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
1 members found this post helpful.
Old 06-14-2011, 09:13 PM   #3
noobquest
LQ Newbie
 
Registered: Jun 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hey, Thanks for the quick reply, My permissions weren't right so I made them into this:

-rwxr-xr-- 1 root root 537 Jun 13 2010 serverstart.sh

now when I do ./serverstart.sh I get "No such file or directory found".. I'm a bit confused now or if I do sh serverstart.sh I get these error's

: command not founde 2:
: command not founde 6:
: command not founde 7:
mv: target `\r' is not a directory

Last edited by noobquest; 06-14-2011 at 09:33 PM.
 
Old 06-14-2011, 09:15 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Please also place any code in [code][/code] tags to make it more readable.
 
Old 06-14-2011, 09:17 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
So permissions are:

r - read - 4
w - write - 2
x - execute - 1

So if we assume you only want root to execute this then simply do:
Code:
chmod 744 serverstart.sh
I would probably add that if this server is to be used for this service you should be looking
at adding it to your startup scripts.
 
Old 06-14-2011, 09:37 PM   #6
noobquest
LQ Newbie
 
Registered: Jun 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for the help grail & chrism01

Last edited by noobquest; 06-15-2011 at 02:05 AM. Reason: missed a helper :)
 
Old 06-15-2011, 02:02 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
If you add my 1st suggestion (set -xv) that will show you exactly what each cmd is doing...
Also, as per my note re '...bash', using sh on top of that is redundant, and usually sh invokes the POSIX shell which is not identical to bash ...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bat to exe barn63 Linux - Software 4 07-17-2008 03:39 PM
linux bat file? Shalk Linux - General 3 07-26-2005 11:07 AM
how to run the *.bat file ztdep Linux - Software 8 07-19-2005 05:36 PM
The Bat! designator Linux - Software 4 11-03-2003 02:54 PM
autoexe.bat genghis Linux - Newbie 4 03-14-2003 10:33 PM


All times are GMT -5. The time now is 01:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration