Question

I need to run several parallel screen (command) sessions in a shell script, but it seems GNU parallel is now working with screen arguments. For example:

#!/bin/sh
parallel --gnu date ::: "-R" "-u"

is working fine, parallel passes both arguments to date command. But:

#!/bin/sh
parallel --gnu screen ::: "-d -m -S t1 bash -c 'echo hi 2>&1 | tee hi.txt'" "-d -m -S t2 bash -c 'echo bye 2>&1 | tee bye.txt'"

gives me for both commands

Error: Unknown option d -m -S t1 bash -c 'echo hi 2>&1 | tee hi.txt'
Use: screen [-opts] [cmd [args]]

If you take a look closely, the - before the "d" argument was removed. Maybe I'm missing anything obvious?

Was it helpful?

Solution

parallel is passing the string "-d -m -S t1 bash -c 'echo hi 2>&1 | tee hi.txt'" as a single argument to screen. So the argument is not getting split into words, and it looks like a really long option starting with -d, which screen can't understand.

I think you want to do something like this, although I haven't tested it or anything:

parallel --gnu "screen -d -m -S t1 bash -c 'echo {} 2>&1 | tee {}.txt'" ::: hi bye
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top