|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
automating a perl script
Hi, I have a perl script that takes in 2 numerical values as ARGV[]. Code:
perl script.pl parameter1 num1 num2 in my case I have 1000's of num1 and num2. I can have them in separate files. Please let me know how to automate this run using shell scripting or using awk, so that I don't have to enter all the values. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Depending on what these input files look like, it may be as simple as Code:
cat filename1 filename2 filename3 | xargs -n 2 perl script.pl parameter1 This will accept files of pure numbers separated by spaces and/or newlines. If that's not what your files look like, please post an example, otherwise we can't help. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
How do I change the above command when I put the 2 numerical values in one file (separated by tab) ( I have 1000's of values (lines) in that file) and I want to direct the output file (1000 files) using '>'. example of my tab delimited parameter file is Code:
38215 41324 41361 41664 41696 42207 42230 42404 42406 42514 |
|
#4
|
|||
|
|||
|
If each line needs a separate output file, then: Code:
OUTPUT=1
while read A B
do
OUTPUT_FILENAME=`printf "%04d" "$OUTPUT"`
perl script.pl $A $B > ${OUTPUT_FILENAME}
done < inputfileIf you only want one output file, the code I already gave you will work. |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
@Lucky Ali: If you're allowed to modify the perl program, you could open the tab delimited parameter file using a file-handle and read its contents inside from inside the program. That way, you wouldn't have to bother about writing a wrapper shell script.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl - automating if statement test | Galt | Shell Programming and Scripting | 3 | 12-31-2009 10:22 PM |
| Automating A Perl Script over a database | fraizerangus | Shell Programming and Scripting | 1 | 10-02-2009 12:26 PM |
| Help in automating dates in ksh script | italia1971luca | Shell Programming and Scripting | 1 | 06-04-2008 06:29 AM |
| cron ? automating a script | hassanj | UNIX for Dummies Questions & Answers | 8 | 12-22-2007 08:29 AM |
| automating sftp script | Rajeshsu | Shell Programming and Scripting | 1 | 07-27-2005 04:06 PM |
|
|