[comp.unix.questions] why doesn't history work in a shell script?

afsipmh@cid.aes.doe.CA (Patrick Hertel) (06/06/90)

 We are slowly converting to UNIX here so forgive me if my question seems
dumb. Is it possible to get history to work inside a shell script - i.e.
get a history of the steps in the script which could then be appended to a file for later perusal? I tried :

          #! /bin/csh
          ls 
          who
          date
          history

 The history command was mute. I even tried redirecting it to /dev/tty and
got diddly. Is it doing anything? If it is what, and where is it going?

-- 
Pat Hertel                 Canadian Meteorological Centre
Analyst/Programmer         Environment Canada
    "Nobody loves me but my mother and she could be jiving too" - B.B. King

jik@athena.mit.edu (Jonathan I. Kamens) (06/07/90)

In article <1990Jun6.131927.22604@cid.aes.doe.CA>,
afsipmh@cid.aes.doe.CA (Patrick Hertel) writes:
|> ["history" doesn't work in a csh shell script]

  There are various things that don't work in shell scripts, and the
history mechanism is one of them.  In fact, doing something like "!!" or
"!-1" won't work either.

  Another example are the "fg" and "bg" operations.  Try this script:

    #!/bin/csh
    sleep 60 &
    fg

and you'll probably get this error:

    No job control in this shell.

  I'm not sure what the solution to these problems is, either than using
another shell :-).

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710