[NTLUG:Discuss] bash Script help

Howard Lee Harkness howard.lee.harkness at gmail.com
Wed Aug 28 14:40:12 CDT 2013


I did a test of the script, with the modification of removing the clear
command and specifying the full path to the sub-script, and it worked ok
under Cygwin (haven't tried on Ubuntu yet).

$ cat test1.sh
#!/bin/bash
#clear
#/usr/local/apps/Wallpaper/set_bg /root/ViewCastWallpaper.bmp

COUNT=10
echo 'Factory Restore will be performed if you no key is pressed in 10
seconds...'
while [ $COUNT -gt 0 ]; do
    echo Factory Restore will be performed in $COUNT seconds..
    echo Press any key to abort!
    echo ' '
    read -sn 1 -t 1 Key

    echo $Key

#if [ $# -eq 2 ] ; then
if test  -z "$Key"; then
    echo no key pressed
    else
    exit 0
fi


    let COUNT=COUNT-1
    #sleep 1s

done

# Test
echo Start Test Now!

/usr/local/bin/test2.sh&


$ cat test2.sh
echo This is a test

Results of run:
$ test1.sh
Factory Restore will be performed if you no key is pressed in 10 seconds...
Factory Restore will be performed in 10 seconds..
Press any key to abort!


no key pressed
/usr/local/bin/test1.sh: line 25: clear: command not found
Factory Restore will be performed in 9 seconds..
Press any key to abort!

[some output omitted for brevity]

no key pressed
Start Test Now!
This is a test



On Wed, Aug 28, 2013 at 2:05 PM, Bobby Wrenn <bobby at wrennest.com> wrote:

> I am having trouble getting a script to execute a script. When the parent
> script ends it should execute the last line of the script. It works all the
> way to the last echo and then just exits. Any help appreciated. I need to
> ship this system to the South Pacific next week.
>
> Here is the script:
> ====================
> #!/bin/bash
> #clear
> #/usr/local/apps/Wallpaper/**set_bg /root/ViewCastWallpaper.bmp
> clear
> COUNT=10
> echo 'Factory Restore will be performed if you no key is pressed in 10
> seconds...'
> while [ $COUNT -gt 0 ]; do
>     echo Factory Restore will be performed in $COUNT seconds..
>     echo Press any key to abort!
>     echo ' '
>     read -sn 1 -t 1 Key
>
>     echo $Key
>
> #if [ $# -eq 2 ] ; then
> if test  -z "$Key"; then
>     echo no key pressed
>     else
>     exit 0
> fi
>
>
>     let COUNT=COUNT-1
>     #sleep 1s
>     clear
> done
>
> #perform the factory restore!
> echo Factory Restore will start now!
>
> ./FactoryRestore.sh&
> ==================
>
> ______________________________**_________________
> http://www.ntlug.org/mailman/**listinfo/discuss<http://www.ntlug.org/mailman/listinfo/discuss>
>



-- 
Howard Lee Harkness
(214) 390-4896


More information about the Discuss mailing list