Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run .bat file on remote Linux

Posted on 2004-10-06
13
Medium Priority
?
1,379 Views
Last Modified: 2006-11-17
Hello Experts. I need to run a .bat file on a dedicated Linux Root Server. Any of you Experts know how to do this, using either WinSCP or Putty?  Or even a regular FTP client, if that's possible?

Many kind thanks in advance,
John
0
Comment
Question by:John Account
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 12245405
You can ftp (or use putty etc) transfer your script to the Linux box, and then use ssh to run
the script. (you can run command with FTP client).

have a look at:
http:Q_20783750.html

FTP script:
http:Q_20702441.html
0
 

Author Comment

by:John Account
ID: 12245632
Yuzh, I'm new to Linux, Putty, and WinSCP...so I'm having a real hard time following you. I'll explain my situation a bit more, and hopefully you'll be able to help me.

I've managed to install the Java Runtime on my Dedicated Linux Root Server. I needed the Java JRE because I'm using a Java Chat Server. To start the Java Chat Server, there are a couple .bat files that I need to execute. When I was hosting these on a local (physical) windows2000 server, there was no problem, because all I needed to do was double-click the .bat files. But now, my server is Linux and it's remote--and I just can't, for the life of me!--seem to be able to run those .bat files.

In WinSCP I right-clicked the file, selected Custom Commands/Execute...only to get error saying: Command "run.bat" failed with return code 127 and error message -bash: line 140: run.bat: command not found.  (Btw, yes, the file has read,write,execute permissions)

In Putty, I tried with: chmod a+x run.bat run.bat....but that apparently doesn't work either, 'cause the chat server isn't running.

I've increased the points to 500, and hope very much that you'll be able to help me out here. Many thanks in advance.
0
 
LVL 38

Accepted Solution

by:
yuzh earned 2000 total points
ID: 12245820
For script to run in a Linux box, the syntax has to be Linux/Unix shell command syntax, the
DOS/windows batch file command syntax will not run on Linux!


>>In Putty, I tried with: chmod a+x run.bat run.bat....but that apparently doesn't work either, 'cause the chat server isn't running.

Do you want to keep the "chat server " running all the time? I can help you to write
a script to make it run at start up so you don't have to worry about to start it in your
application.

Please let me know the program name for your chat server and the FULL path to the
program.


0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 

Author Comment

by:John Account
ID: 12246324
Thanks, yuzh. I appreciate it very VERY much. As I don't know anything about Linux, I'll explain these paths best I can:
When I log in, I'm in the root folder. Then, when I go up a folder, that seems to be the real root--since all the other folders (and, by extent, subfolders) derive from this point forward. Hence, therein, is my home folder; henceforth these following paths leading to the .bat files I need executed.

/home/httpd/vhosts/videopersonals.info/httpdocs/LoveLine/Server/run.bat

/home/httpd/vhosts/videopersonals.info/httpdocs/Server/run.bat

I need to get some sleep now, as it's 3:30 am here; so I'll check back later. If you want to email me any scripts, my email is < # Email address removed by yuzh, Page Editor # >
Many thanks,
John
0
 
LVL 38

Expert Comment

by:yuzh
ID: 12246437
Please do a test for me:

login as root, and then try in the following command:

/home/httpd/vhosts/videopersonals.info/httpdocs/LoveLine/Server/run.bat <Enter>

/home/httpd/vhosts/videopersonals.info/httpdocs/Server/run.bat <Enter>

Please post the screen error messages, and the contains of the two run.bat files.




0
 

Author Comment

by:John Account
ID: 12246521
Couldn't sleep, 'cause had this haunting thought: Maybe those .bat files won't work on Linux. So these are the contents of the .bat files--if that means anything to you, as indicated by their respective paths provided earlier:
     * /home/httpd/vhosts/videopersonals.info/httpdocs/LoveLine/Server/run.bat
java -jar socket.jar 9999
     * /home/httpd/vhosts/videopersonals.info/httpdocs/Server/run.bat
java -jar socket.jar 8082

As you see, the only difference is the port number.

Also, I did your test, and it rendered the following results:
/home/httpd/vhosts/videopersonals.info/httpdocs/LoveLine/Server/run.bat: line 1: java: command not found
/home/httpd/vhosts/videopersonals.info/httpdocs/Server/run.bat: line 1: java: command not found

--going to try to get some sleep, again. Many thanks to you, yuzh.
0
 
LVL 38

Expert Comment

by:yuzh
ID: 12246695
Let's find out is you have java installed in your box first, login as root, and type in the following
command:

find / -type f -name java -print

If the about command can't locate java, you need to install java.

Do worry, someone at EE will help you out, have a nice sleep.

Since we are in different timezone, I suggest that you post a link in the Linux TA and
point to this questions, you might get better responses.

http://www.experts-exchange.com/Operating_Systems/Linux/

Have a nice sleep!
0
 

Author Comment

by:John Account
ID: 12249678
I get the following path  when I type in what you suggested...

/usr/java/j2re1.4.2_05/bin/java
0
 
LVL 4

Expert Comment

by:bytta
ID: 12251632
You should open the files in a text editor and replace "java" with the full path
"/usr/java/j2re1.4.2_05/bin/java"

Again - post the output here...
0
 
LVL 38

Expert Comment

by:yuzh
ID: 12255421
please modify the two .bat files as bytta suggested, and test it again.
0
 
LVL 3

Expert Comment

by:jacauc
ID: 12256143
you might want to execute a 'whereis java' to find out the exact path of the java binary.
then you can try putting the whole path in the bat file
e.g. /usr/bin/java  -jar socket.jar 9999

>>> Make sure that "socket.jar" is for Linux NOT the Windows version!
Yuzh, isn't that the way Java works, (not platform independent) ... so i'd assume it should make a difference.

JohnLucio, are you sure that the .jar file is not actually really corrupt as it states?

Thanks
J



 
0
 

Author Comment

by:John Account
ID: 12258632
no it's not corrupt... I have this software running on a windows machine and it's working just fine.
0
 

Author Comment

by:John Account
ID: 12406192
Hi yuzh. Yours was the solution that worked. I discovered that the reason it wasn't working before was because my jar files don't work with the newest version of the Java JRE. So, after, installing an older JRE, and using your help, everything was smooth. Thank you.
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question