Suppressing "cut" error message in bourne shell script

Suppressing "cut" error message in bourne shell script

Post by Carmen Kelli » Wed, 04 Mar 1992 07:57:27



Using the standard Bourne shell, I'm attempting time the "cat" command on a
standard UNIX file.  I attempt to do it with the following:

        # catentate a standard file
        command="cat /etc/rc.std"            

        # time that puppy
        /bin/time -e $command 1> /tmp/file 2>> /tmp/file
        x=`head -1 /tmp/file | cut -d' ' -f18`
        y=`head -1 /tmp/file | cut -d' ' -f27,29`

        echo $x >> $some_outputfile1 2> /dev/null
        echo $y >> $some_outputfile2 2> /dev/null

"time" times a command and the "-e" flags says to use microsecond precision...

It writes the following to "/tmp/file":
        0.106235 real        0.001052 user        0.039152 sys

It is obviously less than 60 characters in length.  BUT, "cut" SOMETIMES
returns the following error:
  cut: ERROR: line too long

According to my man page, it says:
ERROR:  line too long
                 A line can have no more than 1023 characters or
                 fields, or there is no new-line character.

An "od" of the file reveals the newline character on the end of the file,
so this is bull.  In fact, all I want to do is suppress this error, but no
matter what I try, I cannot.  

If you have any clues, please respond via e-mail, I would GREATLY appreciate
it.


Thanks,

Carmen Kelling          

 
 
 

Suppressing "cut" error message in bourne shell script

Post by Maarten Litmaa » Thu, 05 Mar 1992 03:07:47


\Using the standard Bourne shell, I'm attempting time the "cat" command on a
\standard UNIX file.  I attempt to do it with the following:
\
\       # catentate a standard file
\       command="cat /etc/rc.std"            
\
\       # time that puppy
\       /bin/time -e $command 1> /tmp/file 2>> /tmp/file

Very dangerous!  You let the command write its output and errors
_independently_ to the same file, that is, the output may _overwrite_
the errors and/or vice versa!

Use this instead:

        /bin/time -e $command 1> /tmp/file 2>&1

See sh(1).

\       x=`head -1 /tmp/file | cut -d' ' -f18`
\       y=`head -1 /tmp/file | cut -d' ' -f27,29`
\
\       echo $x >> $some_outputfile1 2> /dev/null
\       echo $y >> $some_outputfile2 2> /dev/null
\
\"time" times a command and the "-e" flags says to use microsecond precision...
\
\It writes the following to "/tmp/file":
\        0.106235 real        0.001052 user        0.039152 sys

Really?  So /etc/rc.std is an empty file?

\It is obviously less than 60 characters in length.  BUT, "cut" SOMETIMES

Obviously 63 is less than 60.

\returns the following error:
\  cut: ERROR: line too long
\
\According to my man page, it says:
\ERROR:  line too long
\                 A line can have no more than 1023 characters or
\                 fields, or there is no new-line character.
\
\An "od" of the file reveals the newline character on the end of the file,
\so this is bull.  In fact, all I want to do is suppress this error, but no
\matter what I try, I cannot.  

Are you sure that the /tmp/file you showed above triggered the error?

\If you have any clues, please respond via e-mail, I would GREATLY appreciate
\it.

I did.

 
 
 

1. How to suppress "Not login shell" message

I followed the excellent advice from a couple of folks in this group to rework
my captive "shutdown" account so that the shutdown script appears in /etc/passwd
as the login shell.  This works fine, but produces the message "Not login shell".
How do I suppress this?

TIA

P.S. Just in case anyone was wondering, "my" network isn't connected to the outside
world.
---

Network Administrator, F-117A Avionics Division
Lockheed Advanced Development Co.

I'm what passes for a Unix guru in my office.  This is a frightening concept.

2. Packaging a new /usr/lib/sendmail

3. DCMA changes; important for Linux users!

4. GETSERVBYNAME()????????????????????"""""""""""""

5. mod_perl module and handlers

6. Can a bourne shell script "background" itself

7. X Server need 10 min to start

8. "turning off" echo in input in bourne shell script

9. UNIX Bourne/Korn Shell Scripting Question on "eval" command.

10. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

11. ps command failed and produced "Bus error" or "Segmentation fault" messages

12. PRINTCAP HAS "SH"(Suppress header) BUT DOES NOT SUPPRESS: HELP.