Run a program and feed her parameters automaticly


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run a program and feed her parameters automaticly
# 1  
Old 10-17-2002
Run a program and feed her parameters automaticly

How can I run a program ('prog') through perl (in unix) and feed her required parameters?

system ("prog \n"); ?????????

now 'prog' ask for parameters and I want the perl script to give them automaticly without humen intervention?
# 2  
Old 10-17-2002
build a menu that the user chooses stuff out of save it to a variable and pass all the variables to the "prog" from the script.
# 3  
Old 10-29-2002
Re: Run a program and feed her parameters automaticly

Quote:
Originally posted by roco
How can I run a program ('prog') through perl (in unix) and feed her required parameters?

system ("prog \n"); ?????????

now 'prog' ask for parameters and I want the perl script to give them automaticly without humen intervention?
You're using "system" in perl, so you're not gathering the results back into perl. If your parameters are in an array called @a, then use this form:
Code:
system /path/to/prog, @a

This will run prog directly, with no intervening shell (a bonus for small programs run a lot).

Have a gander at "man perlfunc" and read the entry therein for "system".

But if you want/need to feed parameters into standard input of prog, use this:
Code:
open(PROG, "| prog") || die "Can\'t start prog";
print PROG $param[0];
print PROG $param[1];
# and so on until you are done
close PROG;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run a program-print parameters to output file-replace op file contents with max 4th col

Hi Friends, This is the only solution to my task. So, any help is highly appreciated. I have a file cat input1.bed chr1 100 200 abc chr1 120 300 def chr1 145 226 ghi chr2 567 600 unix Now, I have another file by name input2.bed (This file is a binary file not readable by the... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

2. Shell Programming and Scripting

How to run csh environment parameters from k-shell script?

Hi Guys, I need to run an alias from a k-shell script ,for example 10204, which points to : source $ORACLE_BASE/scripts/cshrc/10204/.cshrc Meaning , I need to run in my k-shell script with the env settings parameters of the alias. How to do it in k-shell? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

3. Programming

IO Error - xmal feed wont run

Keep getting IO Error and •nonnumeric port: '' (InvalidURL; misconfigured server?) This in relation to RSS feeds. We have done a load of work to try to get RSS feeds working. Now they work. But they wont validate. http://www.ukcitymedia.co.uk/news/rss.php?feed=New_News ... (0 Replies)
Discussion started by: alankeys
0 Replies

4. Shell Programming and Scripting

Run crop with php get parameters

Hail i have a big problem to run cron job with get parameters. My cron path in application is: http://example.org/index.php?module=cron&code=123456 How can i run the cron this path? Help me soon as possible. :confused: (1 Reply)
Discussion started by: sweb
1 Replies

5. Shell Programming and Scripting

Run SQL with parameters from a file

Hello, I need to run a SQL which will get parameters from a .txt file. Basically I need to run following query select * from a table where identity_id in <list of values in A.txt file> A.txt file is having values 1 2 3 4 5 I need the SQL to pick the values from the file and... (2 Replies)
Discussion started by: asdban
2 Replies

6. Shell Programming and Scripting

replace last form feed with line feed

Hi I have a file with lots of line feeds and form feeds (page break). Need to replace last occurrence of form feed (created by - echo "\f" ) in the file with line feed. Please advise how can i achieve this. TIA Prvn (5 Replies)
Discussion started by: prvnrk
5 Replies

7. Shell Programming and Scripting

BASH: how to launch a program with parameters

Hi, I'm a pretty big fan of BASH scripting. I've got a bunch I use for random things and lately a couple issues have been plaguing me. Both are somewhat related, in that they deal with filenames with spaces and "escaped" characters and with launching a program with command line arguements... (5 Replies)
Discussion started by: TinCanFury
5 Replies

8. Shell Programming and Scripting

Run a same script in parallel with diffs parameters

i have script say some_script.ksh that takes an argument I need to run some_script.ksh in background parallely at the sametime with different arguments. Once all the background jobs complete, i need to run this script again in parallel with another 5 set of arguments. Would really... (1 Reply)
Discussion started by: hyennah
1 Replies

9. Programming

Passing Parameters and getting values back from a c program to Shell script

I am having a shell script which has to be called from a C program. I have to pass two parameters to this script. HOw can I do that? eg: int main() { char st1; char str2; // call a shell script call_sh(str1,str2) where call_sh is the name of the shell script. then i need to get the return... (5 Replies)
Discussion started by: Rajeshsu
5 Replies

10. Programming

parameters from my program in c to a .ksh script

hi.. this is my question: it is possible transfer parameters from my program written in C to a .ksh script? how can i do it? i have a program in C, what is called from a .ksh script, and i need what the C program returns some values (parameters) please, help me - any idea thanks ... (2 Replies)
Discussion started by: DebianJ
2 Replies
Login or Register to Ask a Question