469,271 Members | 1,270 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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

3
Example:
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 5692
RonB
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
toolic
70 Expert
chdir

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

open
grep
Jun 29 '10 #4
Oralloy
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
rsm06
3
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");
  4.  
  5. print ("\nEnter the source view\n");
  6. chomp($source = <STDIN>);
  7. system("cleartool startview $source");
  8.  
  9. print ("\nEnter VOB\n");
  10. chomp($vob = <STDIN>);
  11. system("cleartool mount \\$vob");
  12.  
  13. $cwd = ("v:\\$target\\$vob");
  14. chdir ($cwd);
  15.  
  16. system("cleartool findmerge . -ftag $source -print >> c:\\versions.txt");
  17.  
  18. <more script> .....
  19.  
Jul 1 '10 #6
Oralloy
983 Expert 512MB
How are you handling the case when the user enters an invalid value and cleartool fails?
Jul 1 '10 #7
rsm06
3
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
Oralloy
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 zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.