Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

When I enter this command in a terminal window, it works as expected:

ifuse "/home/sadi/mnt"

But it is ineffective when used in a bash script run via a .desktop file.

What can I do to use it like that?

This command (supposed to mount a connected device in the specified folder) is preceded by mkdir -p "/home/sadi/mnt", and followed by nautilus --no-desktop --new-window "/home/sadi/mnt" both of which work perfectly both in terminal and in bash script.

type ifuse output = /home/sadi/usr/bin/ifuse and I have this in my .bashrc: export PATH="${HOME}/usr/bin:${PATH}"

share|improve this question

marked as duplicate by Christopher, GAD3R, Gilles bash Jan 10 at 0:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Let us continue this discussion in chat. – Jacob Vlijm Jan 9 at 22:03
1  
Possible duplicate of How to correctly add a path to PATH? – Gilles Jan 10 at 0:00
up vote 1 down vote accepted

You have set the PATH inside ~/.bashrc, but ~/.bashrc is only fully sourced if the starting shell is interactive.

It is usual to have an statement equivalent to:

[ -z "$PS1" ] && return  # If not running interactively, don't do anything

Which will make your setting of PATH:

export PATH="${HOME}/usr/bin:${PATH}"

simply in-effective if placed after the test for PS1 when used inside a no-interactive script.

share|improve this answer
    
Thanks, but my question is What can I do to use the command ifuse like that? – Sadi Jan 9 at 22:17
1  
@Sadi Place the PATH setting command before the [ -z "$PS1 ] ?. Place a PATH command in ~/.profile (so all scripts will have the correct PATH set) ? Set the PATH in ~/.bash_profile so only bash is affected by the PATH change ? – sorontar Jan 9 at 22:46
    
Thank you very much! I haven't studied this area yet ;-) Simply adding the new PATH section at the end of ~/.profile did the trick although it includes ~/.bashrc earlier which includes If not running interactively, don't do anything strings. – Sadi Jan 10 at 6:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.