Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system command? 1

Status
Not open for further replies.

timcarr

Programmer
Jan 10, 2001
23
ZA
I'm running perl on Windows NT. I need to do a DOS command within one of my scripts. I thought the system command would work for this, but apparently I'm not using the correct syntax... The command I need to run is:
rmtcmd call pgm(library/program) systemname /z

I haven't gotten any errors so far, the script just seems to "hang."
 
Try this:

system('rmtcmd call pgm(library/program) systemname /z');
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
You could try this also...
Code:
exec `rmtcmd call pgm(library/program) systemname /z`

the ` is not a single quote it is a backtick.. to the left of the numeric 1

rgds
AcidHawk
 
exec will cause your program to exit after it's through, so you probly don't want to do this.

it's hanging because of something that's going on in the command you're executing, and in order to get at all the messages it's sending out, you'll need to open it up as a pipe.
try the following:[tt]
$cmd = 'rmtcmd call pgm(library/program) systemname /z';
open(CMD, "$cmd |");
while (<CMD>) {print}
close CMD;
[/tt]

i'm not sure you have to close the pipe, but it probly won't hurt. this will print out everything that the command would normally have printed out. it may be that there's an error, or it may be that it's waiting for user input. if the later is the case, you can supply this input from the perl script by changing the direction of the pipe:[tt]
open(CMD, &quot;| $cmd&quot;);
[/tt]
then sleeping for a bit, and printing to CMD the input it needs.
HTH. &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Closing the pipe -- it's a good idea and seems to be an undefined behaviour. It didn't matter with HPUX 10.0 but the next upgrade bit me -- I had to go around a few scripts and make sure that filehandles and pipes were all explicitly closed.
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
yeah, i figured as much. thanks. &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
I put in the code that stillflame posted and at first I was getting a message that the system name was not in the correct syntax. I corrected this and now the script just hangs again... Any ideas?

Mike- I think the ftp command you were referring to in an earlier post is the quote command. Through an ftp connection I should be able to start the same program by typing:
quote rcmd call library/program

But of course this doesn't work. (I think the quote command has been blocked on our system...for obvious reasons)

Just thought someone might find that useful...
 
This problem is solved, I believe. After not having any luck with the system command I played around a little more the the quote command in ftp and got it to work. After connecting throught ftp with perl I changed the working directory to the library the program was in and then put the following statement:
$ftp->quot('rcmd call [program]');

It was as simple as that...
Figured I'd post this in case anyone ever had any similar problems (although that's not very likely).

Thanks to everyone for their help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top