I am loading a script (whiptail) when the root user logs into their Linux server, which works fine. The thing is, now, when I attempt to run other scripts from the command prompt (or crontab) the initial script is loaded instead, and it looks like the script that I want to run is not.
This is what
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
bash -lc 'ruby some/other/script.rb
When you pass the
-l argument to bash, you're telling it to behave as a login shell; this includes running the user's
If you don't want that behavior, don't pass
bash -c 'ruby some/other/script.rb'
That said, there's no advantage to doing that over just invoking
ruby directly, without any enclosing shell:
If you want other effects of running the user's
.profile, you might set an environment variable to indicate that you want to bypass this behavior:
# in the user's login scripts [ -n "$skip_menu" ] || source /root/menu.sh
skip_menu=1 bash -lc '...your command here...'
...or, if being executed without an enclosing shell...
env skip_menu=1 bash -lc '...your command here...'