set conversion sh > csh

set conversion sh > csh

Post by Joe/Jill Langfi » Fri, 10 May 1996 04:00:00



I have been converting a small script from sh to csh.

I used set in sh in the following manner

set --`wc -l filename`
lines_in file=$1

this works fine but I am not able to find equivalent in csh

any ideas please

 
 
 

set conversion sh > csh

Post by Tom Park » Sat, 11 May 1996 04:00:00


: I have been converting a small script from sh to csh.

: I used set in sh in the following manner

: set --`wc -l filename`
: lines_in file=$1

: this works fine but I am not able to find equivalent in csh

: any ideas please

This should do it:

   set lines_in_file = `wc -l < filename`

Note the "< filename", which simplifies the problem, because wc won't
output the filename if the input is from stdin.

--
+--------------------------------------------------------------------+
| Tom Parker             |  National Center for Atmospheric Research |

+--------------------------------------------------------------------+

 
 
 

set conversion sh > csh

Post by Dave Bro » Sun, 12 May 1996 04:00:00


: I have been converting a small script from sh to csh.
:
: I used set in sh in the following manner
:
: set --`wc -l filename`
: lines_in file=$1
:
: this works fine but I am not able to find equivalent in csh
:
: any ideas please

You can't.

Don't convert shell scripts from sh to csh.  Ew.

--Dave
--
Okay, universe, anything else you can think of to throw at me?

 
 
 

set conversion sh > csh

Post by Ferdinand Mose » Tue, 14 May 1996 04:00:00




> : I have been converting a small script from sh to csh.
> :
> : I used set in sh in the following manner
> :
> : set --`wc -l filename`
> : lines_in file=$1
> :
> : this works fine but I am not able to find equivalent in csh
> :
> : any ideas please

> You can't.

> Don't convert shell scripts from sh to csh.  Ew.

> --Dave
> --
> Okay, universe, anything else you can think of to throw at me?

Dave
Since you are quite far away I can't throw anything at you. But
don't tell things like "You can't", unless you know for sure.

Like Tom Parker posted (and I mailed to the original poster) you
can - of corse - do it. And it's quite simple:

 set lines_in_file = `wc -l < filename`

And if somebody likes to convert sh-scripts into csh: just let it
be done... :-) (BTW: The original poster didn't want to convert a
script from sh to csh. He wrote a new script in csh and just wanted
to know how to set variables with output of external commands...)

Ferdinand
--
--------------------------------------------------------------------

   >>>>      Federal Veterinary Office - Bern, Switzerland     <<<<
  ////  The statements in this article are my personal opinion. \\\\
 |||| ---------------------------------------------------------- ||||
////     Mammas don't let your babies grow up to be cowboys...    \\\\
(-; -------------------------------------------------------------- ;-)

 
 
 

1. Script conversion from csh --> sh

I have just installed xv3.00. The Makefiles invoke './RANLIB.csh'
(seen below) ...

==> RANLIB.csh <==
#!/bin/csh -f
#
# tests to see if the program 'ranlib' exists.  If it does, runs ranlib on
# the first argument (a library name).  Otherwise, does nothing, and returns
#
# written by John Bradley for the XV 3.00 release
# thanks to John Hagan for shell-script hackery
#

echo "executing 'ranlib $1'..."

# Is there a ranlib?  Let's try and then suffer the consequences...
set haveranlib = `ranlib $1 >& /dev/null`

if ( $status ) then
        echo "There doesn't seem to be a ranlib on this system..."
        echo "Don't worry about it."
endif

echo ""
echo ""
==> END: RANLIB.csh <==

Under LINUX i'm only used in using 'bash'. So I try to convert the script
for bash. NOW MY QUESTION: Are the scripts equivalent??

==> RANLIB.sh <==
#    #!/bin/csh -f
#
# tests to see if the program 'ranlib' exists.  If it does, runs ranlib on
# the first argument (a library name).  Otherwise, does nothing, and returns
#
# written by John Bradley for the XV 3.00 release
# thanks to John Hagan for shell-script hackery
#

echo "executing 'ranlib $1'..."

# Is there a ranlib?  Let's try and then suffer the consequences...
haveranlib=`ranlib $1 > /dev/null 2>&1`
STATUS=$?

# echo haveranlib = XXX${haveranlib}XXX
# echo STATUS = $STATUS

if test $STATUS -ne 0 ; then
        echo "There doesn't seem to be a ranlib on this system..."
        echo "Don't worry about it."
fi

echo ""
echo ""
==> END: RANLIB.sh <==

Thanx
Thomas
--
Thomas Grunenberg, Kirchhofallee 12, 2300 Kiel 1, (24103 Kiel)

2. Configuration of fvwm

3. sh -> csh conversion problem

4. Linux Set to Break Through in Consumer Electronics

5. csh to sh conversion utility

6. Solaris 8 and iDS 5.0

7. sh var -> awk var -> sh var

8. Poor NFS performance in SCO Unixware 2.1.2

9. ksh -> sh conversion???

10. Conversion/Utility Unix .sh -> mac?

11. csh -> ksh or ksh -> csh EQUIVALENTS NEEDED....

12. sh->xqf->quake works, fvwm->xqf->quake hangs X?

13. help: csh -> sh