Gentoo Forums
Gentoo Forums
Quick Search: in
Simple BASH script question [solved]
View unanswered posts
View posts from last 24 hours

rackathon
 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Insulator
n00b
n00b


Joined: 21 Mar 2005
Posts: 28
Location: Australia

PostPosted: Mon Jan 07, 2008 5:46 am    Post subject: Simple BASH script question [solved] Reply with quote

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
View user's profile Send private message
platojones
l33t
l33t


Joined: 23 Oct 2002
Posts: 862

PostPosted: Mon Jan 07, 2008 6:18 am    Post subject: Reply with quote

Try changing the line

cd $LOCATION

to

eval "cd $LOCATION"

That causes bash to evaluate variables within the LOCATION variable.
Back to top
View user's profile Send private message
Insulator
n00b
n00b


Joined: 21 Mar 2005
Posts: 28
Location: Australia

PostPosted: Mon Jan 07, 2008 6:56 am    Post subject: Reply with quote

Ok thanks, that works. I'll mark it solved.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum