473,549 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling windows Batch file from ruby program

21 New Member
Hi All,
Is there anyway i can call windows Batch file from ruby program.
I tried the following line, it failed :

cmd.exe /c C:\Documents and Settings\user\D esktop\RUN.bat
Suggest me if you have an answer for this.

Cheers
Jan 30 '08 #1
6 21840
improvcornartist
303 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. system('path/to/file.bat')
The system call will let you do things similar to how you would do them with cmd.
Jan 30 '08 #2
idealfellow
21 New Member
Expand|Select|Wrap|Line Numbers
  1. system('path/to/file.bat')
The system call will let you do things similar to how you would do them with cmd.
Thanks improvcornartis t !!, It works great :)
I see your the only one actively answering Q's.


Thanks
Jan 31 '08 #3
improvcornartist
303 Recognized Expert Contributor
I don't think there are many Ruby/Rails users around here. I'm pretty new to it myself, but I try to help out where I can.

Just a note on using the system call - it will return true or false, depending whether it runs successfully or not. So, you can use it as a test of sorts.
Expand|Select|Wrap|Line Numbers
  1. if system(file.bat)
  2.    #the bat file ran, so do this
  3. else
  4.    #it didn't run successfully, so I need to do this instead
  5. end
  6.  
Jan 31 '08 #4
idealfellow
21 New Member
I don't think there are many Ruby/Rails users around here. I'm pretty new to it myself, but I try to help out where I can.

Just a note on using the system call - it will return true or false, depending whether it runs successfully or not. So, you can use it as a test of sorts.
Expand|Select|Wrap|Line Numbers
  1. if system(file.bat)
  2.    #the bat file ran, so do this
  3. else
  4.    #it didn't run successfully, so I need to do this instead
  5. end
  6.  
Hi improvcornartis t,
I have one doubt pertaining to system call and starting my server.
I use the system call --> system("D:\ruby \bin\selenium.c md")
This starts a server followed by which i would be calling all the methods in my code.
But until the first part of system call ends, i am not able to go to successive methods.
I cant stop the server and then start calling other methods since all methods require server to be up & running.
My question is , Can i start the server and keep it active plus it comes out of the system call and start executing other methods respectively.

Thanks in Advance
Feb 1 '08 #5
improvcornartist
303 Recognized Expert Contributor
I'm not sure how to do this. You might be able to start a new thread.
Expand|Select|Wrap|Line Numbers
  1. Thread.new{system("D:\ruby\bin\selenium.cmd")}
I don't know if that will work, but I'm not sure what else to try. I might have to research this; I would be interested to know how to do it.
Feb 1 '08 #6
idealfellow
21 New Member
I'm not sure how to do this. You might be able to start a new thread.
Expand|Select|Wrap|Line Numbers
  1. Thread.new{system("D:\ruby\bin\selenium.cmd")}
I don't know if that will work, but I'm not sure what else to try. I might have to research this; I would be interested to know how to do it.
Hi,
I tried using Thread.new(syst em('D:\ruby\bin \selenium.cmd') ), it doesnt seem to do what i want, i will be on the watchout , if i find any answers will be updating here!!

cheers
Feb 4 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

14
3534
by: Mark C. | last post by:
I'm trying to call a batch file that I've built using the FileSystemObject and CreateObject("Wscript.Shell"), oShell.Run... in an asp script. Naturally, I can get the script to work from a command line but not from a browser. The page does not throw an error but the oShell.Run... portion of the script doesn't run. Any help would be...
1
5786
by: Bucky Pollard | last post by:
I have a web service that needs to create a batch file and call it (since there are no APIs for the functionality I am looking for). I am using the Process and ProcessStartInfo objects. When I try to call the batch file, it just returns with a return code of 1. When I call cmd.exe, and pass the batch file as a parameter it hangs. After much...
3
7565
by: JoelBrimm | last post by:
I have a batch file that executes a command line utility to do a secure file copy from our server to a 3rd party server. The batch file works fine, but when I call it from the web service the log file shows that it hangs up on the execution of the utility ( an exe ). Batch files without an exe work fine. I also tried running the exe from...
13
5414
by: MLH | last post by:
I have a batch file named GetConf.bat. It contains a line like this: ipconfig /all >c:\MyAppDir\IPdata.txt I believe I could run the line with something like ShellWait by Terry Kreft. Any reason I should run the procedure via a batch file call as opposed to launching the command string directly?
6
20365
by: eric.goforth | last post by:
Hello, I have a simple batch file that I'm trying to call from a VB.NET application: @ECHO OFF IF (%1)==() GOTO END DIR %1 > MYDIR.TXT :END @ECHO ON
0
1361
by: gabrielk43 | last post by:
Hi to all, I have made a web service which creates a batch file in a folder in web server and tries to execute it (in a Windows Server 2003 web server). So far I have managed to create the batch file successfully by adjusting the permissions of the folder it is created in, for the user which is assigned to run the web application for the...
6
34393
by: Studlyami | last post by:
Hey all, I'm trying to create a simple (I think it should be simple) batch file. I want this file to open Internet Explorer 6 go to the webpage SIRIUS Satellite Radio - The Best Radio On Radio and run the javascript: launchPlayer(",",","); Is this possible? I don't know anything about batch files and i only got to the point where i can open the...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7959
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5369
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.