• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bash script not working without absolute path  RSS feed

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bash script in a certain path which is added to the PATH variable:


The scripts inside bin and the PostgreSQL folder have postgres as the owner. When I run any of the scripts inside the bin folder with the full path, the script works:



But when I try the script as is, it complains that it cannot find the script:


 
Stephen Devine
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,

You sure it's added to your path?

I see you're using a macbook, just type 'env' in terminal and check the full pathway there to be sure.

What shell are you using?

If it's still an issue and you do indeed have it in path, check your .profile for any irregularities.

Any issues, let me know.

SD
 
Ahmed Bin S
Ranch Hand
Posts: 385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you setting the PATH? You have to make sure you set it using export so that it becomes an environment variable, ans is therefore available to any child subshell.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
echo $PATH

and make sure it's what you expect
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually have two users user1 and user2. I login as user1 and I have a .bash_profile created in the home directory of user1. In this .bash_profile, I have configured all the PATH and environment variables for java, scala, postgres and much more. Now after logging in as user1, I open a terminal and do a su - user2. When I do an echo $PATH, I get to see a lot less:



My Java, Scala, Postgres and much more that I have configured in the .bash_profile is missing. So it is definitely a PATH issue. How do I make sure that the .bash_profile is shared with all the users?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it boils down to the fact that I want the .bash_profile visible to all users on my Mac.
 
Ahmed Bin S
Ranch Hand
Posts: 385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set the variables in /etc/profile
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of setting the variables in /etc/profile, can I include the .bash_profile in the /etc/profile?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured this out. Not sure if this is a clean approach!

I added the following in my /etc/profile

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!