It is currently Tue, 17 May 2022 02:44:14 GMT



 
Author Message
 Shell Variables: Shell prompt OK, script, NO.

OK, a script like this is run under sh, for which the correct syntax seems
to be
setvar logdate `date "+%Y%m%d"`
(from me reading the man page for sh just now).

Or you could put
#!/bin/csh
at the top of your file which tells your computer to run it using
csh.

--

Stephen Montgomery-Smith              step...@math.missouri.edu
307 Math Science Building             step...@showme.missouri.edu
Department of Mathematics             step...@missouri.edu
University of Missouri-Columbia
Columbia, MO 65211
USA

Phone (573) 882 4540
Fax   (573) 882 1869

http://www.**-**.com/ ~stephen



 Sun, 18 Nov 2001 03:00:00 GMT   
 Shell Variables: Shell prompt OK, script, NO.
In article <3755d7dc.7493...@news.golden.net>,
        willon...@bigfoot.com (Willondon Donovan) writes:

Try this in your script:

#! /bin/csh

set logdate = (`date +%Y%m%d`)
echo $logdate | tee test.dat

Refer to the manpage for csh, esp. the section "Expressions"
for a discussion on precedence of + % ` and ( as well as the
"Lexical structure", "Command substitution" and
"Quotations ..." sections.

Your own $HOME/.cshrc and $HOME/.login might afford some
helpful examples/hints.

You might also like to lurk in comp.unix.shell for some
very interesting and enlightening discussions on scripting.
If you post your question there, certain pedants would
recommend against naming your script "test" (there's already
a /bin/test) and/or for using csh for scripting at all (some
folks read a certain article in O'Reilly's "Unix Power
Tools" and take it as Gospel)

I won't bug ya, though  :)

If you're /really/ interested in scripting, i recommend getting
a copy of "UNIX Shell Programming" by Stephen G. Kochan and
Patrick H. Wood.  My copy is so old i don't know if its publisher
(Hayden Books) or ISBN are still valid.

HTH

cheers,
        tom

--
Applicants must have at least five years' experience with Windows 98 ...

        remove NO_SPAM. from address to reply



 Sun, 18 Nov 2001 03:00:00 GMT   
 Shell Variables: Shell prompt OK, script, NO.

try

logdate=`date "+%Y%m%d"`
^      ^
no     no
set    spaces!

m.



 Mon, 19 Nov 2001 03:00:00 GMT   
 Shell Variables: Shell prompt OK, script, NO.

This is what my "sh" manual page says:
--------------------------------------

     setvar variable value
             Assigns value to variable. (In general it is better to write
             variable=value rather than using setvar.  Setvar is intended to
             be used in functions that assign values to variables whose names
             are passed as parameters.)

So, yes you can use setvar but it is better not to.

csh is "evil" IMHO.  Write shell scripts in ksh/sh/bash.  
--
Shaun Rowland   rowl...@cis.ohio-state.edu
IICF System Administrator       DL798
http://www.cis.ohio-state.edu/~rowland



 Mon, 19 Nov 2001 03:00:00 GMT   
 Shell Variables: Shell prompt OK, script, NO.
In article <37570069.1885...@news.golden.net>,
        willon...@bigfoot.com (Willondon Donovan) writes:

Actually,i just occassionally see this requirement in career ads
posted, of course, by those endearing social benefactors: headhunters.  
Everytime i see it, it tickles my funnybone.  Sometimes i consider
applying to them as a lark, but i'm underqualified :)

cheers,
        tom

P.S.
I wonder if there's any free csh tutorials on the Web ... i haven't
tried looking, but something might turn up.

--

        remove NO_SPAM. from address to reply



 Mon, 19 Nov 2001 03:00:00 GMT   
 
   [ 5 post ] 

Similar Threads

1. flexible prompt in shells via shell-script

2. export variables to calling shell in a shell-script

3. export variables to calling shell in a shell-script

4. file contents into variable, or global variable from shell script

5. Passing a variable from a Perl script to a shell script

6. Passing a variable between shell script and perl script

7. Convert Bash shell script to Korn shell script

8. shell script within shell script (general question)

9. Shell Script Help (C-Shell Script)

10. Shell script invoking other shell scripts


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software