Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i edit my .profile to have a unix commad run automatically?

Status
Not open for further replies.

linuxMaestro

Instructor
Jan 12, 2004
183
US
How do i edit my .profile to have a unix commad run automatically?
 
man vi

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Or if you want the command to run at the end of your .profile (to invoke a menu, say):

echo "/path/to/command" >> $HOME/.profile
 
The short answer is that it's obvious... you just run it.


But be sure you know what you're doing if you try running a program from your [tt].profile[/tt]. With a lot of shells (including Bash, the typical Linux default) [tt].profile[/tt] is sourced only for login shells.

That means when you log in from the console, [tt].profile[/tt] will run, but it will not run for subsequent shells you spawn from that one.

It also means that, when you log in from a graphical display manager like XDM, the [tt].profile[/tt] will run, but not in a shell you'll ever actually see. In some graphical environments, if the [tt].profile[/tt] runs a command that wants input, the session will just hang because there is no place for the input to come from. (That's why a menu would be a bad idea).


The [tt].bashrc[/tt] (only for Bash, of course) is sourced for every interactive instance of the shell except for login shells. (Of course, you can have it sourced from your [tt].profile[/tt] to have it work for login shells, too).


Finally, in Bash, you can test the variable [tt]$-[/tt] to determine whether or not a shell is interactive; it will contain "i" if it is.

(Quoted from the Bash info page:)
Code:
case "$-" in
*i*)       echo This shell is interactive ;;
*) echo This shell is not interactive ;;
esac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top