shanenin Posted September 23, 2005 Report Share Posted September 23, 2005 what is the proper way to run fortune. I currently have the fortune command at the bottom of my .bashrc file. It seems to work well, but I read this warning in my .bashrc# /etc/skel/.bashrc:# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/skel/.bashrc,v 1.8 2003/02/28 15:45:35 azarah Exp $# This file is sourced by all *interactive* bash shells on startup. This# file *should generate no output* or it will break the scp and rcp commands.so i am guessing since fortune produces output, this could cause problems. I know slackware uses forture, I wonder what method that distro uses. Quote Link to post Share on other sites
jcl Posted September 23, 2005 Report Share Posted September 23, 2005 Looks like it adds this script to /etc/profile.d/#!/bin/sh# Print a fortune cookie for interactive shells:if [[ $- = *i* ]]; then echo fortune fortunes fortunes2 linuxcookie echofi Quote Link to post Share on other sites
shanenin Posted September 23, 2005 Author Report Share Posted September 23, 2005 I am not sure where to put it one my gentoo system. If I use /etc/profile, it does not seemed to get sourced the first time I open a shell, when I first open an xterm fortune does not run. But if I change to user of root using '-' , like su - shane, then fortune runs. I hardly use scp, so maybe I will just leave it in my .bashrc Quote Link to post Share on other sites
naraku9333 Posted September 23, 2005 Report Share Posted September 23, 2005 All I did was add fortune futurama at end of /etc/bash/bashrc and it puts the fortune for all accounts. Quote Link to post Share on other sites
jcl Posted September 23, 2005 Report Share Posted September 23, 2005 (edited) The script above is fine in bashrc. Edited September 23, 2005 by jcl Quote Link to post Share on other sites
shanenin Posted September 23, 2005 Author Report Share Posted September 23, 2005 All I did was add fortune futurama at end of /etc/bash/bashrc and it puts the fortune for all accounts.<{POST_SNAPBACK}>if you read the top of the file it says that will break scp Quote Link to post Share on other sites
shanenin Posted September 23, 2005 Author Report Share Posted September 23, 2005 what does this line doif [[ $- = *i* ]]shane@mainbox ~ $ echo $-himBH Quote Link to post Share on other sites
jcl Posted September 23, 2005 Report Share Posted September 23, 2005 Tests whether $- contains 'i', indicating an interactive shell. Quote Link to post Share on other sites
shanenin Posted September 23, 2005 Author Report Share Posted September 23, 2005 (edited) shane@mainbox ~ $ echo $-himBHmake no sence to me Edited September 23, 2005 by shanenin Quote Link to post Share on other sites
jcl Posted September 23, 2005 Report Share Posted September 23, 2005 RTFM $ info bash 'Bash Features' 'Interactive Shells' 'Is this Shell Interactive?' Quote Link to post Share on other sites
shanenin Posted September 23, 2005 Author Report Share Posted September 23, 2005 RTFM oxymoron above :-)cool, I never used the info command before. I fond this6.3.2 Is this Shell Interactive?--------------------------------To determine within a startup script whether or not Bash is runninginteractively, test the value of the `-' special parameter. Itcontains `i' when the shell is interactive. For example: case "$-" in *i*) echo This shell is interactive;; *) echo This shell is not interactive;; esacit just is Quote Link to post Share on other sites
jcl Posted September 23, 2005 Report Share Posted September 23, 2005 (edited) The parameter - contains the option flags that are set in the shell. 'i' corresponds to the option '-i', which starts an interactive shell. A partial list of flags can be found in the documentation for the 'set' builtin in the bash manpage. ('himBH' = history enabled, interactive, monitor mode (nicer interactive job control), brace expansion, '!' history substitution.)I can't believe you had never used info It's the primary documentation for the GNU project; the half-assed manpages are secondary (at best) to the texinfo docs. It's one of the GNU project's more irritating quirks. Edited September 23, 2005 by jcl Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.