Re: Scripting

From: Thomas Adam (thomas_adam16_at_yahoo.com)
Date: 11/07/04

  • Next message: Hugo Vanwoerkom: "Re: Enhancing video"
    Date: Sat, 6 Nov 2004 23:10:56 +0000 (GMT)
    To: Silvan Villiger <vsilvan@stud.phys.ethz.ch>, debian-user@lists.debian.org
    
    

     --- Silvan Villiger <vsilvan@stud.phys.ethz.ch> wrote:

    > I've started to learn scripting in linux. But I have some troubles
    > understandig the redirection of the streams. I tried to test whether a
    > directory already exists using the ls command (didn't find a bether
    > solution) and whenever ls doesn't find such a directory it writes an

    [ -d /some/directory ] && echo "directory exists" >&2 || echo "nope. does
    not exist" >&2

    Which will echo the reply to stderr.

    > Another example I had, was when I tried to compile a latex-file in a
    > script. How can i prevent it from writing compiling-informations to the
    > shell which started the script?

    thescript 2> /dev/null

    would redirect all errors to the bit-bucket. If you wanted to blank the
    entire lot:

    thescript > /dev/null 2>&1

    (or, if you don't care for portability, the command above is the same as:

    thescript &> /dev/null )

    HTH,

    -- Thomas Adam

    =====
    "The Linux Weekend Mechanic" -- http://linuxgazette.net
    "TAG Editor" -- http://linuxgazette.net

    "<shrug> We'll just save up your sins, Thomas, and punish
    you for all of them at once when you get better. The
    experience will probably kill you. :)"

     -- Benjamin A. Okopnik (Linux Gazette Technical Editor)

            
            
                    
    ___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Hugo Vanwoerkom: "Re: Enhancing video"

    Relevant Pages

    • Re: Editable input from the console windows
      ... stdin, stdout, and stderror in relationship to pipe commands. ... I understand the fundamentals behind redirection. ... The exec command adds to the confusion as well. ... I learning the syntax and build upon a previously working script. ...
      (comp.unix.shell)
    • Re: Reg Crontab
      ... Instead of a redirection add an echo command to the script. ... Best thing is to handle the redirection in the script; that way you can put a timestamp into the log file name. ...
      (AIX-L)
    • Re: bsdutils: /usr/bin/script doesnt wait for command to finish before exiting
      ... *>* The script command fails to wait for the command that it is executing to finish. ... It is the I/O redirection from /dev/null which is the culprit. ... The _culprit_ is the buggy code in script.c, for which I provided a patch ...
      (Ubuntu)
    • Re: edit and write multiple files with ed/ed/vi script
      ... IO redirection makes it into the ed clauses then it's time to consider ... A pipe specifies that the next command in line gets its ... is feeding it to the command in the pipe, ... Realistically you'll need to put the ed command in a script and have ...
      (comp.unix.admin)
    • Re: Problems trying to configure Linux laptop to print to Windows XP shared printer
      ... map to guest = Never ... check password script = ... enumports command = ... ldap delete dn = No ...
      (comp.os.linux.setup)