You are not logged in.
Hi
In a terminal if I enter 'bash --login -c 'mybashfunction'
there should be a search order specified by --login for a startup script to be executed
before mybashfunction is invoked.
In Debian I place . /source/myscripts in ~/.profile. In arch
it does not work.
thanks
Murray
Offline
Bash manpage excpt.:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
When an interactive login shell exits, or a non-interactive login shell executes the exit builtin command, bash reads and executes commands from the file ~/.bash_logout, if it exists.
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.
strace the command if you're still unsure which considered file hits.
Also "it does not work" is a worthless error descritption (see the newbie corner stickies): it doesn't indicate which step fails. Reading ~/.profile, interpreting it, reading /source/myscripts - really that absolute path? - or interpreting that? Each step can fail and make it "does not work".
Edit: yeah - code tags no good for manpage ... quotes
Last edited by seth (2018-05-02 06:41:09)
Offline
Thanks for the reply.
1) "it does not work" is a worthless - Yes you are right. should have said:
"bash --login -c 'list_folders /zdir'" produces
bash: list_folders: command not found
the script file did not get source from ~/.profile to the bash function was not found.
2) your cut and paste excerpt:
I am familiar with this and have followed it. My script file is
sourced from ~/.profile. It works in Debian for me and not in arch. Hence my
post. You did not comment on whether this is right or wrong in arch.
It would be of more help if you had tried it out to see if it actually works the way
your pasted code says it should.
3) strace produced 6 pages of code that is meaningless to me.
4) absolute path issue. I don't understand. what should I code instead of
something like:
. /mylibrary/myscripts.sh
Murray
Offline
it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists
I am familiar with this and have followed it. My script file is sourced from ~/.profile.
No, clearly it isn't and therefore I suspect you haven't. Do ~/.bash_profile or a ~/.bash_login exist? If so, your source command is in the wrong file. I suspect on debian you may not have these on your system. If you created a new user following the wiki-guided defaults, you will havea ~/.bash_profile which would explain your symptoms.
Last edited by Trilby (2018-05-02 11:40:25)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
strace bash --login -c 'list_folders /zdir' 2>&1 | grep -E '(open|stat)' | grep $HOMEThe question reg. the absolute path was meant to point out that "/source/myscripts" is a somewhat odd file (you'd expect anything "mystuff" somewhere in $HOME, thus the question whether the path is actually correct and should not be ~/source/myscripts or similar)
Offline
Thanks again
Issue resolved.
1)it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists
Yes. I already knew that but I missed ~/.bash_profile existed. Removed it and problem solved.
2) Yes, This is a throwaway environment while I am learning arch.
just put it there to keep it simple while testing.
Not sure how to mark this as solved.
Thanks gain
Murray
Offline
You can mark your thread as [Solved] by editing your first post and prepending it to the title.
Offline