Last active
February 19, 2019 22:46
-
-
Save jeffrade/9af16cd8f70097cc181ad2ab12988f4b to your computer and use it in GitHub Desktop.
Bash script that will pop a line item for a file and pass it to a command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Starting..." | |
param=`sed -e 1$'{w/dev/stdout\n;d}' -i~ params.out` | |
while [[ -n $param ]]; do | |
echo "Starting process for $param..." | |
<some-command> $param & | |
curr_pid=`echo $!` | |
echo "Current pid is $curr_pid" | |
is_running="yes_it_is" | |
while [[ -n $is_running ]]; do | |
echo "Sleeping..." | |
sleep 5s | |
is_running=`ps -ww -fp "$curr_pid" | grep <some-useful-regex-for-command>` | |
#echo "debug: $is_running" | |
done | |
echo "Last process for $param completed!" | |
echo "Popping next param..." | |
param=`sed -e 1$'{w/dev/stdout\n;d}' -i~ params.out` | |
done | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO
<some-command>
pass in as command line arg to this script.<some-useful-regex-for-command>
pass in as command line arg to this script.