ldstern@rodan.acs.syr.edu (Larry Stern) (04/04/91)
I have a simple script question I can't seem to get answered here. I would like my .login file to ask me if I want to read news, something to the effect of: Read new (y/n)? if "y" then rn -s15 else [prompt] Thanks in advance for any help. -Larry Stern -- Larry Stern LDSTERN@RODAN.ACS.SYR.EDU
jc@raven.bu.edu (James Cameron) (04/04/91)
>>>>> On 3 Apr 91 16:55:01 GMT, ldstern@rodan.acs.syr.edu (Larry Stern) said:
Larry> I have a simple script question I can't seem to get answered here. I would
Larry> like my .login file to ask me if I want to read news, something to the effect
Larry> of:
Larry> Read new (y/n)?
Larry> if "y" then rn -s15
Larry> else [prompt]
Larry> Thanks in advance for any help.
Larry> -Larry Stern
What you would want to do is to read the manual page with the shell you are running.
But, if you are using csh or tcsh, try this:
echo -n "Read news now? (Y/N): "
set REPLY = $<
if ($REPLY == "Y" || $REPLY == "y") then
rn -s15
endif
Hope that helps.
--
-- James Cameron (jc@raven.bu.edu)
Signal Processing and Interpretation Lab. Boston, Mass (617) 353-2879
------------------------------------------------------------------------------
"But to risk we must, for the greatest hazard in life is to risk nothing. For
the man or woman who risks nothing, has nothing, does nothing, is nothing."
(Quote from the eulogy for the late Christa McAuliffe.)
gab@tcs.com (Gary A. Bolles) (04/05/91)
In article <JC.91Apr3153259@raven.bu.edu> jc@raven.bu.edu (James Cameron) writes: > >But, if you are using csh or tcsh, try this: > > echo -n "Read news now? (Y/N): " > set REPLY = $< > if ($REPLY == "Y" || $REPLY == "y") then > rn -s15 > endif > > >Hope that helps. Just a word about doing stuff like this in your .login (if you must)... If rn exits abnormally for some reason, you may find that tasks appearing after it in your .login go undone. At least this was my experience with csh under 4.3BSD. I'd suggest that you make this routine the last thing you do in .login - just in case. Good luck. -- Gary A. Bolles | Teknekron Communications Systems, Inc. Software Configuration Manager | 2201 Dwight Way, Berkeley, CA, 94704 gab@tcs.com or uunet!tcs!gab | (415) 649-3595 Keep America Singing - SPEBSQSA
pfinkel@cbnewsb.cb.att.com (paul.d.finkel) (04/10/91)
In article <1991Apr3.165501.25434@rodan.acs.syr.edu> ldstern@rodan.acs.syr.edu (Larry Stern) writes: >I have a simple script question I can't seem to get answered here. I would >like my .login file to ask me if I want to read news, something to the effect >of: > Read new (y/n)? > if "y" then rn -s15 > else [prompt] How about: echo "Read news[CR=y/n]? \c" read ans if [ "$ans" = "" ] then news else : fi -- Family motto: Semper ubi, sub ubi. mail: attmail!pfinkel "My name is Fink, whaddaya think, I press pants for nothing?" (Punch line to corny joke that my father always told!)
pfinkel@cbnewsb.cb.att.com (paul.d.finkel) (04/10/91)
In article <1991Apr10.144150.10011@cbfsb.att.com> pfinkel@cbnewsb.cb.att.com (paul.d.finkel) writes: >In article <1991Apr3.165501.25434@rodan.acs.syr.edu> ldstern@rodan.acs.syr.edu (Larry Stern) writes: >>I have a simple script question I can't seem to get answered here. I would >>like my .login file to ask me if I want to read news, something to the effect >>of: >> Read new (y/n)? >> if "y" then rn -s15 >> else [prompt] > >How about: > > echo "Read news[CR=y/n]? \c" > read ans > if [ "$ans" = "" ] > then > news > else > : > fi > Sorry, it could have been echo "Read news[CR=yes/n] \c" read ans if [ ! "$ans" ] etc,etc. -- Family motto: Semper ubi, sub ubi. mail: attmail!pfinkel "My name is Fink, whaddaya think, I press pants for nothing?" (Punch line to corny joke that my father always told!)
itkin@mrspoc.Transact.COM (Steven M. List) (04/12/91)
pfinkel@cbnewsb.cb.att.com (paul.d.finkel) writes: >In article <1991Apr10.144150.10011@cbfsb.att.com> pfinkel@cbnewsb.cb.att.com (paul.d.finkel) writes: >>In article <1991Apr3.165501.25434@rodan.acs.syr.edu> ldstern@rodan.acs.syr.edu (Larry Stern) writes: >>>I have a simple script question I can't seem to get answered here. I would >>>like my .login file to ask me if I want to read news, something to the effect >>>of: >>> Read new (y/n)? >>> if "y" then rn -s15 >>> else [prompt] >> >>How about: >> >> echo "Read news[CR=y/n]? \c" >> read ans >> if [ "$ans" = "" ] >> then >> news >> else >> : >> fi >> > >Sorry, it could have been > > echo "Read news[CR=yes/n] \c" > read ans > if [ ! "$ans" ] > > etc,etc. How about if he said ".login" assuming that it must be the C shell? /bin/echo "Read news (y/n) [y] \c" set reply = `line` if ( "$reply" == "y" || "$reply" == "" ) then rn... endif -- +----------------------------------------------------------------------------+ : Steven List @ Transact Software, Inc. :^>~ : : Chairman, Unify User Group of Northern California : : itkin@Transact.COM :
mjt@jersey (Mike Tietel) (04/13/91)
In article <1991Apr10.145212.10124@cbfsb.att.com> pfinkel@cbnewsb.cb.att.com (paul.d.finkel) writes: >In article <1991Apr3.165501.25434@rodan.acs.syr.edu> ldstern@rodan.acs.syr.edu (Larry Stern) writes: >>I have a simple script question I can't seem to get answered here. I would >>like my .login file to ask me if I want to read news, something to the effect ^^^^^^ > >How about: > > echo "Read news[CR=yes/n] \c" > read ans > if [ ! "$ans" ] > etc,etc. of course if you want something to work in .login (i.e., csh): echo -n "Read news[y|n] " set c=($<) if ( $c != n ) then rn else ... endif -- Mike Tietel mjt@jersey.orb.mn.org Euler Solutions, Inc. ..!orbit!jersey!mjt
pravin@eniac.seas.upenn.edu (05/13/91)
In a previous article mjt@jersey.UUCP (Mike Tietel) writes: |In article <1991Apr10.145212.10124@cbfsb.att.com> pfinkel@cbnewsb.cb.att.com (paul.d.finkel) writes: |> |> echo "Read news[CR=yes/n] \c" |> read ans |> if [ ! "$ans" ] |> etc,etc. | |of course if you want something to work in .login (i.e., csh): | | echo -n "Read news[y|n] " | set c=($<) | if ( $c != n ) then | rn | else | ... | endif This does not work for me in my .profile file. I get an error at the first line. BTW, my login shell is bash. Does this script not work with bash, or I am doing something wrong. I would appreciate any help!! thanks.. -- pravin (215)573-4360 (h) (215)898-3211 (w)
chet@odin.INS.CWRU.Edu (Chet Ramey) (05/13/91)
In article <42993@netnews.upenn.edu> pravin@eniac.seas.upenn.edu writes: >> >> echo "Read news[CR=yes/n] \c" >> read ans >> if [ ! "$ans" ] >> etc,etc. > >This does not work for me in my .profile file. I get an error at the >first line. BTW, my login shell is bash. Does this script not work >with bash, or I am doing something wrong. The bash built-in echo is a 10th Edition Unix-style echo; it needs the -e flag to enable backslash-escaped character interpretation. This should work for you: echo -n "Read news[CR=yes/n] " read ans if [ ! "$ans" ] etc,etc. Chet -- Chet Ramey Internet: chet@po.CWRU.Edu Case Western Reserve University NeXT Mail: chet@macbeth.INS.CWRU.Edu ``Now, somehow we've brought our sins back physically -- and they're pissed.''