Last active
December 18, 2015 10:59
-
-
Save kamranzafar/5772617 to your computer and use it in GitHub Desktop.
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/sh | |
# Ad-hoc shell script generator | |
# Kamran ([email protected]) | |
# Generates script (default=doit) for the executed commands | |
# After generation, commands can be re-run using the doit script | |
echo "Ad-hoc shell script genertor started" | |
SCRIPT_FILE=$1 | |
if [ -z "$1" ] | |
then | |
SCRIPT_FILE="doit" | |
fi | |
rm -f $SCRIPT_FILE | |
echo "#!/bin/sh" >> $SCRIPT_FILE | |
echo >> $SCRIPT_FILE | |
while read inputline | |
do | |
if [ "$inputline" = "exit" ] | |
then | |
break | |
fi | |
$inputline | |
echo "$inputline" >> $SCRIPT_FILE | |
echo >> $SCRIPT_FILE | |
done | |
chmod -f +x $SCRIPT_FILE | |
echo "Done!" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment