Wednesday, July 9, 2008

pause before copy : bash script newbie


I already discussed how to write pause function in bash scripting in one of my older post.

Now a simple script to show how that function can be used.

Situation: Your application say "hxes" can process one file at a time (files under its input dir /opt/hxes/input/). You have to copy a set of *.toprocess files to its incoming folder /opt/hxes/input/ in a way such that before copying it waits till you press enter.


#!/bin/sh

f_pause(){
read -p "$*"
}

for file in `ls *.toprocess`
do
echo "copying $file"
f_pause "Hit Enter key to continue."
cp $file /opt/hxes/input/
done

No comments:

© Jadu Saikia www.UNIXCL.com