471,892 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

I need help with running multiple commands within one system call.

I run a perl script from my c:\
the command I want to run is first change directory from C:\ to z:
then in Z: I want to run the dir command and performs some more commands (example findstr) and send output to a file.
Next I want to cd in R:\ and so same as last step.

How can I make this happen in perl?
Jun 28 '10 #1

✓ answered by toolic

8 5805
589 Expert Mod 512MB
Oops, I posted my comment in the wrong thread. [post removed]

Let me finish another post, then I'll come back and answer your question.
Jun 29 '10 #2
70 Expert

Jun 29 '10 #3
589 Expert Mod 512MB
Instead of using the system function to execute findstr, I'd use open and grep.

Jun 29 '10 #4
983 Expert 512MB
Why do you need a single system call?

One option you have is to build and execute a CMD script, if you're willing to go to that level of effort.

Also, what's wrong with using some form of fileglobing to build your list?
Jul 1 '10 #5
Tahnks to all who replied. I used the chdir and system command to do what I wanted. Here is the script I am now succesfuly running:

Expand|Select|Wrap|Line Numbers
  1. print ("\nEnter the target view ");
  2. chomp($target = <STDIN>);
  3. system("cleartool startview $target");
  5. print ("\nEnter the source view\n");
  6. chomp($source = <STDIN>);
  7. system("cleartool startview $source");
  9. print ("\nEnter VOB\n");
  10. chomp($vob = <STDIN>);
  11. system("cleartool mount \\$vob");
  13. $cwd = ("v:\\$target\\$vob");
  14. chdir ($cwd);
  16. system("cleartool findmerge . -ftag $source -print >> c:\\versions.txt");
  18. <more script> .....
Jul 1 '10 #6
983 Expert 512MB
How are you handling the case when the user enters an invalid value and cleartool fails?
Jul 1 '10 #7
I am using the until loop to look for the 3 valid entries that require the input. Until the entires are found to be valid which is checked one at a time against an array the user cannot proceed.
Jul 1 '10 #8
983 Expert 512MB
Its just that I didn't see any error checking on the system calls. My thought was out of scope for your question, though.

Good luck getting it done.
Jul 1 '10 #9

Post your reply

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

Similar topics

3 posts views Thread by gmtonyhoyt | last post: by
reply views Thread by haynes george | last post: by
2 posts views Thread by francescomoi | last post: by
1 post views Thread by qilin | last post: by
1 post views Thread by stemp1ar | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

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.