473,382 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Calling windows Batch file from ruby program

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\Desktop\RUN.bat
Suggest me if you have an answer for this.

Cheers
Jan 30 '08 #1
6 21793
improvcornartist
303 Expert 100+
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
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 improvcornartist !!, It works great :)
I see your the only one actively answering Q's.


Thanks
Jan 31 '08 #3
improvcornartist
303 Expert 100+
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
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 improvcornartist,
I have one doubt pertaining to system call and starting my server.
I use the system call --> system("D:\ruby\bin\selenium.cmd")
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 Expert 100+
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
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(system('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
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...
1
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...
3
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...
13
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...
6
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
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...
6
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.