[Thread Prev][Thread Next][Index]

Re: [ferret_users] ferret -script with history



Hi Patrick,
What ferret -script does is to use a simpler command-line reading method, as is used in -server mode.  It doesn't use the same readline calls that are used in other modes, and this means that the commands aren't available to echo back with the up-arrows.  I don't see a way to change that behavior.

A simple method, if not very elegant, might be to have the script just type itself out before exiting.  If myscript.jnl has in it:
  say "We are in 2009"
  sp cat myscript.jnl
  exit/prompt
Then if it is executed either by piping it into Ferret with
> ferret < myscript.jnl
or with
> ferret -script myscript.jnl
then the commands would at least be available to the user.

Ansley

Brockmann Patrick wrote:
Ryo Furue a écrit :
Patrick,

| I am wondering how to launch ferret with a pre-existing script and get
| a prompt AND history ready to use ?
| | If myscript.jnl is the simple script bellow:
| say "We are in 2009"
| exit/prompt
| | Then if I type
| ferret -script myscript.jnl
| I launch ferret and run the script, get the prompt BUT no history | features (use of arrows up/down).
| | Any idea on how to get the load of a script at starting ?

Does this meet your needs?

  $ ferret
        NOAA/PMEL TMAP
        FERRET v6.02
        Linux(g77) 2.4.21-32 - 04/30/07
        21-Jan-09 11:57

  yes? go myscript.jnl
  say "We are in 2009"
  We are in 2009
  exit/prompt
  yes?                                                   
Probably you don't need "exit/prompt" in this case.
 
Yes you need this line to get the prompt back and be ready to use ferret with the loaded script.
Another idea is that you write a shell script like

  #!/bin/sh
  rc=$HOME/.ferret
  rc_bak=$HOME/.ferret-bak
  mv $rc $rc_bak
  cat $rc_bak "$1" > $rc
  shift
  ferret "$@"
  rm $rc
  mv $rc_bak $rc

call it, say, "ferret-init-with", and use it as

  $ ferret-init-with myscript.jnl . . . .
 
Seems not so easy to implement if I have heterogeneous platform users (Linux and Windows).

What about this feature for next release...
Patrick


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement