[SOLVED] Adding command to ~/.bash_profile fails

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
markfilipak
Level 5
Level 5
Posts: 904
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

[SOLVED] Adding command to ~/.bash_profile fails

Post by markfilipak » Sat Oct 12, 2019 1:42 am

SOLUTION: viewtopic.php?f=90&t=303450&p=1700234#p1700234 & viewtopic.php?f=90&t=303450&p=1700346#p1700346

I have a feeling I'm going to learn a lot in this topic.

Here is my command to start TBird: "/media/mark/TBird Linux/thunderbird" --profile /media/sf_email/0ysydkep.default.
It works in Terminal.
It works in Cinnamon Menu

Now, I want it to execute on start so that TBird automatically launches.
It does not work in ~/.bashrc -- which prompted me to do some reading.
I created ~/.bash_profile.
It does not work in ~/.bash_profile (meaning: TBird doesn't launch on start).

What am I doing wrong?

Note: Some may naturally ask why I don't enable TBird in 'System Settings' 'Startup Applications'. The answer is that as far as the system is concerned, TBird is not installed -- really, it isn't installed -- so enabling it in 'System Settings' 'Startup Applications' does nothing.
Last edited by markfilipak on Sat Oct 12, 2019 8:07 pm, edited 2 times in total.

User avatar
karlchen
Level 20
Level 20
Posts: 11335
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Adding command to ~/.bash_profile fails

Post by karlchen » Sat Oct 12, 2019 7:04 am

Hi, Mark.

Basically, both files $HOME/.bash_profile and $HOME/.bashrc are the wrong locations in order to launch an automatic startup application, where your intention is to launch Thunderbird precisely once after you have logged in to the Mint desktop.

Why your commandline does not work when put into $HOME/.bash_profile or $HOME/.bashrc?
You would have to post the content of both files for us to inspect them and tell why the commandline will not work, when invoked from .bash_profile or .bashrc.

Be glad it does not work from .bashrc for you:
.bashrc is read whenever you start a new bash instance, explicitly or implicitly. This would result in Thunderbird instances being started up over and over again. Not what you want.

.bash_profile is only read and executed provided bash is used as a login shell. By default this only applies to the pseudo console monitors <ctrl><alt><f1> to <ctrl><alt><f6> (tty1 to tty6), but not to the graphical terminal windows on the Mint desktop.

Your commandline "/media/mark/TBird Linux/thunderbird" --profile /media/sf_email/0ysydkep.default suggests that Thunderbird gets launched from 2 external devices.
When you log into the Mint desktop, it will take a few seconds till these external media have been mounted. Only afterwards the commandline can succeed.

So your initial idea of creating an automatic startup entry, invoking this commandline, was the right approach. Only very likely the entry got started before /media/mark and /media/sf_email were available.
So maybe adding a delay of 10 seconds or 20 seconds to the automatic startup job will be sufficient to make it work as intended.

Regards,
Karl
Image
Linux Mint 19.2 32-bit xfce Desktop, Total Commander 9.22a 32-bit
Haß gleicht einer Krankheit, dem Miserere, wo man vorne herausgibt, was eigentlich hinten wegsollte. (Goethe)

markfilipak
Level 5
Level 5
Posts: 904
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

Re: Adding command to ~/.bash_profile fails

Post by markfilipak » Sat Oct 12, 2019 2:09 pm

karlchen wrote:
Sat Oct 12, 2019 7:04 am
Hi, Mark.

Basically, both files $HOME/.bash_profile and $HOME/.bashrc are the wrong locations in order to launch an automatic startup application, where your intention is to launch Thunderbird precisely once after you have logged in to the Mint desktop.
How do I do it, Karl? How do I start TBird automatically? Cron? Would I have to run cron? Oh, doG, I hope not. Man articles never tell you how to do anything. They're written by Martians.
Why your commandline does not work when put into $HOME/.bash_profile or $HOME/.bashrc?
You would have to post the content of both files for us to inspect them and tell why the commandline will not work, when invoked from .bash_profile or .bashrc.
Here's .bashrc

Code: Select all

# added by mark is at end

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm|xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
	# We have color support; assume it's compliant with Ecma-48
	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
	# a case would tend to support setf rather than setaf.)
	color_prompt=yes
    else
	color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    if [[ ${EUID} == 0 ]] ; then
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
    else
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] '
    fi
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h \w \$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

if [ -x /usr/bin/mint-fortune ]; then
     /usr/bin/mint-fortune
fi

# added by mark
alias ls="ls -g --group-directories-first"
Here's .bash_profile

Code: Select all

"/media/mark/TBird Linux/thunderbird" --profile /media/sf_email/0ysydkep.default
.bash_profile is only read and executed provided bash is used as a login shell. By default this only applies to the pseudo console monitors <ctrl><alt><f1> to <ctrl><alt><f6> (tty1 to tty6), but not to the graphical terminal windows on the Mint desktop.
I don't know how to interpret what you wrote, Karl. To the best of my knowledge, I don't run 'pseuto console monitors'.

Is there a startup log? I searched through /var/log/ and couldn't find one. Mint doesn't have a program like Total Commander, so I can't search for particular text such as 'bashrc'.

Perhaps the log I seek is given the name of a daemon or something else.
So your initial idea of creating an automatic startup entry, invoking this commandline, was the right approach. Only very likely the entry got started before /media/mark and /media/sf_email were available.
So maybe adding a delay of 10 seconds or 20 seconds to the automatic startup job will be sufficient to make it work as intended.
What is the name of the "automatic startup job"? Thanks.

User avatar
MrEen
Level 14
Level 14
Posts: 5052
Joined: Mon Jun 12, 2017 8:39 pm

Re: Adding command to ~/.bash_profile fails

Post by MrEen » Sat Oct 12, 2019 2:24 pm

markfilipak wrote:
Sat Oct 12, 2019 2:09 pm
Man articles never tell you how to do anything. They're written by Martians.
Agreed! See here.
markfilipak wrote:
Sat Oct 12, 2019 2:09 pm
What is the name of the "automatic startup job"? Thanks.
Try

Code: Select all

sleep 10; "/media/mark/TBird Linux/thunderbird" --profile /media/sf_email/0ysydkep.default
in Startup Applications.

Hope that helps.

markfilipak
Level 5
Level 5
Posts: 904
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

Re: Adding command to ~/.bash_profile fails

Post by markfilipak » Sat Oct 12, 2019 2:48 pm

MrEen wrote:
Sat Oct 12, 2019 2:24 pm
markfilipak wrote:
Sat Oct 12, 2019 2:09 pm
Man articles never tell you how to do anything. They're written by Martians.
Agreed! See here.
I'm not quite sure what that is. I tried this:

Code: Select all

mark@mark-VirtualBox ~ $ mkdir -p ~/bin
mark@mark-VirtualBox ~ $ curl -o ~/bin/tldr https://raw.githubusercontent.com/raylee/tldr/master/tldr
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8894  100  8894    0     0  15194      0 --:--:-- --:--:-- --:--:-- 15203
mark@mark-VirtualBox ~ $ chmod +x ~/bin/tldr
mark@mark-VirtualBox ~ $ tldr
No command 'tldr' found, did you mean:
 Command 'tdr' from package 'devtodo' (universe)
tldr: command not found
markfilipak wrote:
Sat Oct 12, 2019 2:09 pm
What is the name of the "automatic startup job"? Thanks.
Try

Code: Select all

sleep 10; "/media/mark/TBird Linux/thunderbird" --profile /media/sf_email/0ysydkep.default
in Startup Applications.

Hope that helps.
OHMYGOD. I didn't know single command lines could be added to 'Startup Applications' !!

You see, Linux apps have no 'Help' , so finding what to do is like looking for software Easter Eggs.

Unfortunately, it doesn't work. I clicked 'Run now' and nothing happened... does 'sleep 10' maybe mean 10 hours? -- Just kidding. :lol:

SOLUTION CONTINUES: viewtopic.php?f=90&t=303450&p=1700346#p1700346
Last edited by markfilipak on Sat Oct 12, 2019 8:06 pm, edited 1 time in total.

User avatar
MrEen
Level 14
Level 14
Posts: 5052
Joined: Mon Jun 12, 2017 8:39 pm

Re: Adding command to ~/.bash_profile fails

Post by MrEen » Sat Oct 12, 2019 3:55 pm

After your next boot, or log out/in tldr should work. That's when ~/bin will automatically be added to your PATH.

Not sure about the startup command at the moment.

User avatar
catweazel
Level 19
Level 19
Posts: 9521
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Adding command to ~/.bash_profile fails

Post by catweazel » Sat Oct 12, 2019 5:23 pm

MrEen wrote:
Sat Oct 12, 2019 2:24 pm
See here.
That link deserves its own thread. Brilliant find, so thank you.
¡uʍop ǝpısdn sı buıɥʇʎɹǝʌǝ os ɐıןɐɹʇsnɐ ɯoɹɟ ɯ,ı

User avatar
MrEen
Level 14
Level 14
Posts: 5052
Joined: Mon Jun 12, 2017 8:39 pm

Re: Adding command to ~/.bash_profile fails

Post by MrEen » Sat Oct 12, 2019 5:25 pm

catweazel wrote:
Sat Oct 12, 2019 5:23 pm
MrEen wrote:
Sat Oct 12, 2019 2:24 pm
See here.
That link deserves its own thread. Brilliant find, so thank you.
You're most welcome!

markfilipak
Level 5
Level 5
Posts: 904
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

Re: Adding command to ~/.bash_profile fails

Post by markfilipak » Sat Oct 12, 2019 5:51 pm

MrEen wrote:
Sat Oct 12, 2019 5:25 pm
... You're most welcome!
Bumper sticker seen:
Honk if you play saxophone
:lol:

User avatar
MrEen
Level 14
Level 14
Posts: 5052
Joined: Mon Jun 12, 2017 8:39 pm

Re: Adding command to ~/.bash_profile fails

Post by MrEen » Sat Oct 12, 2019 6:04 pm

markfilipak wrote:
Sat Oct 12, 2019 5:51 pm
MrEen wrote:
Sat Oct 12, 2019 5:25 pm
... You're most welcome!
Bumper sticker seen:
Honk if you play saxophone
:lol:
That's redundant! :wink:

markfilipak
Level 5
Level 5
Posts: 904
Joined: Sun Mar 10, 2013 8:08 pm
Location: Ohio (formerly California), USA

Re: Adding command to ~/.bash_profile fails

Post by markfilipak » Sat Oct 12, 2019 6:13 pm

MrEen wrote:
Sat Oct 12, 2019 2:24 pm
... Try sleep 10; "/media/mark/TBird Linux/thunderbird" --profile /media/sf_email/0ysydkep.default in Startup Applications.

Hope that helps.
sleep 10; "/media/mark/TBird Linux/thunderbird" --profile /media/sf_email/0ysydkep.default didn't work, but "/media/mark/TBird Linux/thunderbird" --profile /media/sf_email/0ysydkep.default does work -- no delay needed.

Thanks so much!

PS: Thanks for 'tldr'. That's going to save my a** (and probably avoid posts here). :)
Last edited by markfilipak on Sat Oct 12, 2019 6:19 pm, edited 2 times in total.

User avatar
MrEen
Level 14
Level 14
Posts: 5052
Joined: Mon Jun 12, 2017 8:39 pm

Re: [SOLVED] Adding command to ~/.bash_profile fails

Post by MrEen » Sat Oct 12, 2019 6:17 pm

Cool. Don't know why the delay didn't work. I'm sure I've seen that syntax used before. Maybe the lack of space after sleep?

Post Reply

Return to “Newbie Questions”