I'm at a loss here. I'm trying to create a script to automate some things. I have a function exitfn() it is supposed to catch the ctrl+c and execute. I do this because, if you look, below the function this operation sometimes hangs and I only need to run it. It does not finish so I tell the ask the user to hit ctrl+c and it should run the function but instead I get back:
/bin/grep: /var/lib/mrtg/cfgs/ .cfg: No such file or directory.
My thoughts:
- Is it even running the first comman correctly?
Am I using the whole trap thing wrong?
#!/bin/bash echo "Enter the name of the device: > " read dName echo "Now enter device type [cpu, ram, : > " read dType echo "Enter the devices actual value with % symbol: > " read aValue echo "Enter the desired threshold with % symbol: > " read dValue echo "Grounding..." n=`locate thresholdHandler.pl` cd ${n%thresholdHandler.pl} echo "Hit Ctrl+C to continue......" exitfn() { trap SIGINT echo; echo "Running second command, wait 3 seconds" sleep 3 ./thresholdHandler.pl output above $dname.$dType $dValue $aValue echo "Complete" exit } trap "exitfn" INT ./thresholdHandler.pl output above $dName.$dType $aValue $dValue sleep 10 trap SIGINT
Thank You for your time.
fiin the end?