[Thread Prev][Thread Next][Index]

Re: [ferret_users] create go files on the fly



Hi Ryo,

Thanks very much esp for the explanation why spawn doesn't work. Your suggestion makes a lot of sense to me. The only drawback is to lose ferret syntax highlighting (I use vim) embedded in shell code. But I found I could recover that by manually setting syntax file (:set syntax=ferret).

Thanks,
David

On Thu, Aug 21, 2008 at 9:19 PM, Ryo Furue <furue@xxxxxxxxxx> wrote:
David,

| I have a script in which a chunk of code is used several times, so I
| copied and pasted it into several different places. Then I thought,
| well, maybe I can shorten my script by wrapping that chuck of code
| in an additional go file, and if possible, on the fly. So I tried
| the following,
|
| sp cat << EOF > tmp.jnl
|
| my code here
|
| EOF
|
| go tmp.jnl
| ...
| go tmp.jnl
| ...
| ...
| sp rm -f tmp.jnl
|
| But it doesn't work. The lines in between two EOF didn't find
| themselves in the file tmp.jnl. Has anyone done similar tricks
| before? I really like the idea of creating files on the fly...

I think it's much more flexible to use a shell script as your
"main" program, like so:

  #!/bin/sh
  cat <<EOF > tmp.jnl

  your code here

  EOF

  cat <<EOF > tmp2.jnl
    go tmp.jnl
    ...
    go tmp.jnl
    ...
    ...
  EOF

  ferret -script tmp2.jnl

  rm tmp.jnl tmp2.jnl

Your original style doesn't work because "SP" invokes a shell
and exits before the next line of your Ferret script starts.

Cheers,
Ryo


[Thread Prev][Thread Next][Index]

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

Privacy Policy | Disclaimer | Accessibility Statement