I have a script that begin like this
#!/bin/bash
VALKYRIE=~/myProjects/valkyrie
source $VALKYRIE/cluster.conf
but when I run it it returns
line 2: ~/myProjects/valkyrie/cluster.conf: No such file or directory
but the file exist and when I run source ~/myProjects/valkyrie/cluster.conf it runs fine.
Any idea? I set VALKYRIE variable elsewhere so hard-code in the path isn't an option.
source "${VALKYRIE}/cluster.conf". – Sparhawk Jun 01 '13 at 03:41source ~/myProjects/valkyrie/cluster.confworks, when you replace the last two lines of the script? (Or from the command line?) – Sparhawk Jun 01 '13 at 03:52~not expanding properly. When I run your script with an intentionally fake path, the error doesn't say~, but expands the path. Can you try replacing the~in your script with the absolute path? Also, try running the following in a scriptecho ~. – Sparhawk Jun 01 '13 at 04:04~did the trick. Thanks a lot! – Khoi Jun 01 '13 at 04:10~and work out why it doesn't work? – Sparhawk Jun 01 '13 at 04:12$HOMEinstead of~. – Sparhawk Jun 01 '13 at 04:16VALKYRIE="~/myProjects/valkyrie"-- quotes would suppress the expansion of the tilde. – glenn jackman Jun 01 '13 at 04:40VALKYRIE=~/myProjects/valkyriewithout quotes inside~/.pam_environment– Khoi Jun 01 '13 at 07:15~/.pam_environmentis not a shell script, so it doesn't do the common things you'd expect from a shell, such as tilde expansion and parameter expansion, so neither~nor$HOMEwill be replaced. If you move that line to~/.profileinstead, and addexportin front, it should work. – geirha Jun 01 '13 at 08:41~/.pam_environment. Well I don't need to use~nor$HOME, works for me. – Khoi Jun 01 '13 at 09:24