CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
When i call a .bat file in a System() function , it is not releasing control after that bat executed

 



hydpm
User

Jul 24, 2008, 8:27 AM

Post #1 of 3 (1890 views)
When i call a .bat file in a System() function , it is not releasing control after that bat executed Can't Post

hi,

Here is one interesting problem i had. I executed a batch file which starts the my server.

When the below code ran, it is able to start the server. But in the console when i try to stop that and performing some other thing it is not terminating.

When i press Ctrl+C and it is giving a message Terminate the Signal , when i say Yes still it is repeatedly asking the same. then i am closing the console window to get rid of that:

---------------------------------------------------------------------------------

[VV] DEBUG [main] SeleniumClient.<init>(112) | Proxy host=localhost
[VV] DEBUG [main] SeleniumClient.<init>(113) | Proxy port=4444
[VV] DEBUG [main] SeleniumClient.<init>(114) | Browser spec=*chrome
[VV] DEBUG [main] SeleniumClient.<init>(115) | App URL=http://10.0.14.199:9090
[VV] DEBUG [main] SeleniumClient.<init>(116) | App context=VoiceConsole
[VV] DEBUG [main] DbUnitStepRunner.startTesting(177) | DbUnit dataset dir: C:\Ra
dium\VoiceConsole\test_data\data\dbunit
Jul 24, 2008 11:22:09 AM org.apache.cxf.service.factory.ReflectionServiceFactory
Bean buildServiceFromClass
INFO: Creating Service {http://server.radium.vocollect.com}RadiumWebService from
class com.vocollect.radium.server.RadiumWebService
Jul 24, 2008 11:22:09 AM org.apache.cxf.service.factory.ReflectionServiceFactory
Bean buildServiceFromClass
INFO: {http://server.radium.vocollect.com}steps part element name {http://server
.radium.vocollect.com}steps references element {http://server.radium.vocollect.c
om}steps
{http://server.radium.vocollect.com}return part element name {http://server.radi
um.vocollect.com}return references element {http://server.radium.vocollect.com}r
eturn

Jul 24, 2008 11:22:09 AM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be http://localhost:8282/Radium
2008-07-24 11:22:09.860::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2008-07-24 11:22:09.875::INFO: jetty-6.1.x
2008-07-24 11:22:09.953::INFO: Started SelectChannelConnector@0.0.0.0:8282
Terminating on signal SIGINT(2)

C:\MTA\main\PerlModules\Vocollect-VoiceConsole-Util\lib\Vocollect\VoiceConsole\U
til>Terminate batch job (Y/N)? Y
'Y' is not recognized as an internal or external command,
operable program or batch file.

C:\MTA\main\PerlModules\Vocollect-VoiceConsole-Util\lib\Vocollect\VoiceConsole\U
til>cls
Terminate batch job (Y/N)?
C:\MTA\main\PerlModules\Vocollect-VoiceConsole-Util\lib\Vocollect\VoiceConsole\U
til>
Terminate batch job (Y/N)? y
'y' is not recognized as an internal or external command,
operable program or batch file.

C:\MTA\main\PerlModules\Vocollect-VoiceConsole-Util\lib\Vocollect\VoiceConsole\U
til>
Terminate batch job (Y/N)? Y
'Y' is not recognized as an internal or external command,
operable program or batch file.

C:\MTA\main\PerlModules\Vocollect-VoiceConsole-Util\lib\Vocollect\VoiceConsole\U
til>cls
Terminate batch job (Y/N)?
C:\MTA\main\PerlModules\Vocollect-VoiceConsole-Util\lib\Vocollect\VoiceConsole\U
til>

----------------------------------------------------------------------------------------



Code: The code causing above effect. I think there is some thing issue with the way System() function works when we ran Batch file in it.

print "$hostname is NOT listening on tcp port $portnumber.\n";
print "START The Radium and Selenium Servers\n";

my $driveletter = $ENV{"SYSTEMDRIVE"};
chomp($driveletter);
my $radpath = "$driveletter\\Radium\\bin\\radium-ws.bat";
chdir("$driveletter\\Radium\\bin\\");
system("radium-ws.bat");



-----------------------

I appreciate if some one helps why it is behaving like that and solution to get rid of that.



-raj


travs69
Novice

Jul 24, 2008, 4:36 PM

Post #2 of 3 (1868 views)
Re: [wingsof5r] When i call a .bat file in a System() function , it is not releasing control after that bat executed [In reply to] Can't Post

Try using the start command before the .bat file
system("start blah.bat")


stenrap
Novice

Jul 30, 2008, 12:11 PM

Post #3 of 3 (1724 views)
Re: [wingsof5r] When i call a .bat file in a System() function , it is not releasing control after that bat executed [In reply to] Can't Post

On Windows you can add an extra argument to the system() function, which effectively tells it to launch a child and return:

system(1, "radium-ws.bat");

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives