Re: How to script the creation of a text file, with 4/5 lines of text
From: Chris F.A. Johnson (c.f.a.johnson_at_rogers.com)
Date: 09/30/03
- Next message: Andreas Kahari: "Re: how to logon to 30+ machines and put a job run in background and then logout automatically in a script file?"
- Previous message: Stephen Copp: "How to script the creation of a text file, with 4/5 lines of text"
- In reply to: Stephen Copp: "How to script the creation of a text file, with 4/5 lines of text"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Sep 2003 07:05:14 GMT
On Tue, 30 Sep 2003 at 02:44 GMT, Stephen Copp wrote:
> Hello all,
>
> I'm trying to script the creation of a file with a few lines of text. The
> thing is that this text contains special characters and filepaths. For
> example, the text file I want to create looks something like the following:
>
> THIS = ( that )
> PATH = ( /this/is/a/test/test.jar )
> (${PATH}) -> (${THIS})
> test....
#!/bin/sh
echo "THIS = ( that )
PATH = ( /this/is/a/test/test.jar )
(\${PATH}) -> (\${THIS})" > FILE
> This is what I get when I do the following:
> # echo "THIS = ( that ) PATH = ( /this/is/a/test/test.jar ) (${PATH}) ->
Are you doing this as the superuser (root)? If so, DON'T!
> (${THIS}) test...." > test.out
> THIS: Undefined variable
Are you using csh (or tcsh) for scripting? Again, DON'T.
For reasons why not, see:
<http://www.grymoire.com/Unix/CshTop10.txt>
<http://www.grymoire.com/Unix/Csh.html#uh-0>
<http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/>
Use a Bourne-type shell for scripting (sh, bash, ksh, ash, zsh).
> Adding a '/' in front of the '$' doesn't help either:
Why would it? The escape character is \.
> # echo "THIS = ( that ) PATH = ( /this/is/a/test/test.jar ) (/${PATH}) ->
> (/${THIS}) test...." > test.out
> THIS: Undefined variable
>
> I'm trying to do this within a script, so I can't use the following because
> I need a ctrl-C to break:
> cat > test.out
That will read stdin, not the succeeding lines in the file.
> THIS = ( that )
> PATH = ( /this/is/a/test/test.jar )
> (${PATH}) -> (${THIS})
> test....
>
> Does anyone know how I get around this? Thanks for any help you can give
> me.
For information on writing shell scripts, you would do better in
the comp.unix.shell newsgroup.
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Next message: Andreas Kahari: "Re: how to logon to 30+ machines and put a job run in background and then logout automatically in a script file?"
- Previous message: Stephen Copp: "How to script the creation of a text file, with 4/5 lines of text"
- In reply to: Stephen Copp: "How to script the creation of a text file, with 4/5 lines of text"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|