473,372 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 5911
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
985 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
985 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
985 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

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

Similar topics

0
by: Will Seay | last post by:
At the end of this message I've pasted a script we're trying to modify slightly. I don't believe it is VBscript or javascript but these are the closest groups I could find with my limited...
4
by: PalB | last post by:
How to stop running multiple instances of my App in C#? Thanx
3
by: gmtonyhoyt | last post by:
Okay, this one's a tough one for me to explain so this might take a few e-mails to get the idea across. Here's what I got though. I have this application running on a Sun/Solaris machine,...
0
by: haynes george | last post by:
hi .. I was reading the tutorial "Extending and Embedding the python interpreter" available with python .. http://www.python.org/doc/2.2.3/ext/ext.html As per given in the tutorial i...
2
by: francescomoi | last post by:
Hi. On PHP4, I want to execute these two system commands: # cd /home/foo1/foo2 # /usr/local/php/bin/php /home/foo1/foo2/script.php If I do it via shell, it works ok. But If I do: -------
13
by: Avi | last post by:
Hi, Is there a UNIX C system command that will let me copy a file? I am looking for something similar to "cp" that can be called within a C program. I know of the "link" system call but this...
1
by: qilin | last post by:
I have perl program which use system() to call another c program meanwhile the c program also use system() to execute a linux command line ....but not sure why it doesn't work. yes, the perl...
1
by: stemp1ar | last post by:
I am wondering if it possible to open a single process and run multiple commands on that process and check standard error and standard out after each command? Has anyone done something similar...
1
by: houh | last post by:
I have a java app that generates openoffice docs. When I run the java app in a shell script, as: export JAVA_HOME=/opt/corp/projects/metrics/Java/jdk1.5.0_07/bin/java export...
10
by: Atropo | last post by:
Hi all, Having several strings how do I construct variable to pass to system(): Lets say the date command string str = "14/10/08 19:06:09"; strDD = str.substr(0,2); strMM =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.