简体   繁体   中英

GNU Parallel Setup on Unix command line prompt

I have ac program that takes an input through either the standard input main(argc) or an input via a scanf() call.

It is setup such that if there is no suitable standard input that it uses scanf() calls to ask for an input.

I am trying to use gnu parallel to launch multiple versions of this program with different input values. The program takes 2 integers as inputs, so for example:

printf("\nEnter Start Line (0 for first line) :");
scanf ("%d",&startline);

printf("\nEnter End Line:");
scanf ("%d",&endline);

The inputs would also be incremental, so if the inputs to the first file were 0 10 then the second file inputs would be 10 20 third file 20 30 etc.

I am just having difficulty constructing the right call to make what I want happen. Does anyone have any thoughts on this?

Thanks

So your program reads from STDIN and you want the input chopped up in 2 line chunks that are each passed to your program:

cat your_input | parallel --pipe -N2 your_program

Example:

seq 10 | parallel --pipe -N2 echo "NEW"\; cat

Spend an hour walking through the tutorial. Your command line will love you for it. http://www.gnu.org/software/parallel/parallel_tutorial.html#gnu_parallel_tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM