From 287fc41c1c884edd9bceca94f73fc38ad49d253b Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Fri, 2 Jan 2015 11:33:40 +0100 Subject: [PATCH] sem: --shebang-wrap example in manual. --- src/parallel | 2 +- src/parallel.pod | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/parallel b/src/parallel index 9399337e..f818fb26 100755 --- a/src/parallel +++ b/src/parallel @@ -955,7 +955,7 @@ sub parse_options { sub init_globals { # Defaults: - $Global::version = 20141229; + $Global::version = 20150101; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; diff --git a/src/parallel.pod b/src/parallel.pod index b4234fed..b981dcb5 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -1534,6 +1534,9 @@ On FreeBSD B is needed: debian.org freenetproject.org +There are many limitations of shebang (#!) depending on your operating +system. See details on http://www.in-ulm.de/~mascheck/various/shebang/ + =item B<--shebang-wrap> @@ -3010,6 +3013,37 @@ same time: seq 3 | parallel sem --id mymutex sed -i -e 'i{}' myfile +=head1 EXAMPLE: Mutex for a script + +Assume a script is called from cron or from a web service, but only +one instance can be run at a time. With B and B<--shebang-wrap> +the script can be made to wait for other instances to finish. Here in +B: + + #!/usr/bin/sem --shebang-wrap -u --id $0 --fg /bin/bash + + echo This will run + sleep 5 + echo exclusively + +Here B: + + #!/usr/bin/sem --shebang-wrap -u --id $0 --fg /usr/bin/perl + + print "This will run "; + sleep 5; + print "exclusively\n"; + +Here B: + + #!/usr/local/bin/sem --shebang-wrap -u --id $0 --fg /usr/bin/python + + import time + print "This will run "; + time.sleep(5) + print "exclusively"; + + =head1 EXAMPLE: Start editor with filenames from stdin (standard input) You can use GNU B to start interactive programs like emacs or vi: