![]() NOTE: /etc/bashrc has warnings about modifying it which likely should be heeded, instead relying on its recommendations to put customizations in another file that it calls automatically.Īnd this outputs on my little laptop/fedora server sitting next to me in my home office, demonstrating similar command execution from its. I checked and that, too, worked as expected. bashrc templates have this in them: #Source global definitions That said, I'm guessing that if you want your reminder to work for everyone, then you would simply put it in /etc/bashrc, as all my. And they're easy to check - log out and back in!! bashrc file that loads every time I log in. I have a number of commands at the end of my. read usernumber1 echo 'Enter another number and hit 'Enter''. The Bash read command allows ut to do just that. Not sure how/why, but in 2023 all of these workarounds are superfluous on AWS EC2 running Amazon Linux, and I suspect on other Linux as well. To allow a user to enter a value that the script will use, you need to be able to capture the users keyboard input. I see this was last asked 10 years ago, but us noobs keep coming along. As mentioned, it really isn't the way to do it, but works for now. This soulution assumes having automatic log-on set up. Su - YOURUSERNAME -c '/usr/local/bin/script_file.sh -optional -flags' # Run the script as YOURUSERNAME instead of root: Until ] & ] doĮcho "Xserver hasn't started or other error occurred. # Wait until X is running and required user logged in: # Description: runs '/usr/local/bin/script_file.sh -optional -flags' at startup, when xserver has started and YOURUSERNAME is logged on. # Provides: script_file.sh startup at boot Since my script requires xserver and user to be logged on, I created initfile which waits after bootup for xserver and user to be logged on and then executes the script: #! /bin/bash Don't know why it doesn't work for me perhaps it has something to do with my display manager auto logon workaround, just a guess.Īnother solution would be adding script shortcuts to global file that gets executed at startup, for instance /etc/rc.local. OP did not indicated what OS the script runs on. /home/nixcraft/scripts The following line sets the shell variable i to /home/nixcraft/scripts: i dirname / home / nixcraft / scripts / foo.sh echo 'i' OR i (dirname / home / nixcraft / scripts / foo.sh) echo 'i' In bash script use 0 instead of /home/nixcraft/scripts/foo. It's dirty one though.įirst of all, using ~/.bash_profile, ~/.bash_login, ~/.profile or even /etc/profile.d/ should be preferred methods instead (here's good reading on the subject). ![]() ![]() ![]() Okay, I've found a solution to my initial problem. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |