View Single Post
slvr32's Avatar
Posts: 168 | Thanked: 104 times | Joined on Feb 2008 @ California, USA
#5
You probably want to make the script run in a subshell, and take advantage of your environment to make sure you're sitting in the appropriate directory...

for example...

Code:
#!/bin/sh

dest=/media/mmc2/gvm-backup.tar

(
    cd $HOME
    tar cvf $dest .gvm
)

and...

Code:
#!/bin/sh

src=/media/mmc2/gvm-backup.tar

(
    cd $HOME
    if [ -f $src ]; then
        tar xvf $src
    else
        echo "$src doesn't exist"
    fi
)
Also, 'ls -l' should show you the permissions on the scripts after you chmod +x them, and you'll probably see something like

-rwxr-xr-x (755 permissions, for example)

where the parentheses in each script cause the code in parentheses run in a subshell, cd to the home directory, run the other commands, etc... without changing the directory outside of the context of that subshell.

Last edited by slvr32; 2009-03-22 at 03:59.
 

The Following 2 Users Say Thank You to slvr32 For This Useful Post: