| View previous topic :: View next topic |
| Author |
Message |
Insulator n00b

Joined: 21 Mar 2005 Posts: 28 Location: Australia
|
Posted: Mon Jan 07, 2008 5:46 am Post subject: Simple BASH script question [solved] |
|
|
I have a really simple script to deal with my digital camera which is as follows:
| Code: | #!/bin/bash
gphoto2 --list-files
echo "Which files would you like to load?"
read FILENUMS
echo "Where would you like them loaded to?"
read LOCATION
cd $LOCATION
gphoto2 --get-file $FILENUMS |
The problem I'm trying to figure out is why if I just enter '~' or '$HOME' when asked for the LOCATION it gives an error. | Quote: | | line 7: cd: ~: No such file or directory |
It's not a big deal, it works fine otherwise, I just don't understand it because an 'echo ~' or 'echo $HOME' gives the response I would expect (full path of my home directory).
Last edited by Insulator on Mon Jan 07, 2008 6:57 am; edited 1 time in total |
|
| Back to top |
|
 |
platojones l33t

Joined: 23 Oct 2002 Posts: 862
|
Posted: Mon Jan 07, 2008 6:18 am Post subject: |
|
|
Try changing the line
cd $LOCATION
to
eval "cd $LOCATION"
That causes bash to evaluate variables within the LOCATION variable. |
|
| Back to top |
|
 |
Insulator n00b

Joined: 21 Mar 2005 Posts: 28 Location: Australia
|
Posted: Mon Jan 07, 2008 6:56 am Post subject: |
|
|
| Ok thanks, that works. I'll mark it solved. |
|
| Back to top |
|
 |
|