×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

system command?

system command?

system command?

(OP)
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."

RE: system command?

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.

RE: system command?

You could try this also...

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

RE: system command?

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:
$cmd = 'rmtcmd call pgm(library/program) systemname /z';
open(CMD, "$cmd |");
while (<CMD>) {print}
close CMD;

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:
open(CMD, "| $cmd");
then sleeping for a bit, and printing to CMD the input it needs.
HTH.

"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."

RE: system command?

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.

RE: system command?

yeah, i figured as much.  thanks.

"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."

RE: system command?

(OP)
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...

RE: system command?

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close