[HPADM] Re: RE: help with a script - condition to check the size of t he file and initiate ftp

cbeerse_at_gmail.com
Date: 05/17/05

  • Next message: Kasula, Sridhar Rao: "[HPADM] directory size limit..."
    Date: Tue, 17 May 2005 14:51:58 +0200
    To: BAKHSHESH Kazem <BAKHSHEK@ESSILOR.fr>
    
    

    BAKHSHESH Kazem wrote:

    > Hi

    > INF=pop
    >
    > x=$(cat $INF | wc -c)
    1: redundant use of `cat`. You could have used `x=$(wc -c $INF)` or `x=$(wc -c <
    $INF)`.
    2: redundant use of `wc` at all: the test is about the file size which the
    command `test` can read from the filesystem without the need to read the file.
    >
    > if [ $x -ne 0 ]; then
    > echo "You can lunch the ftp command"
    > else
    > echo "$INF is empty"
    > fi

    A little more nice:

    #!/bin/sh
    # ftp /path/to/file if it is not empty
    transferfile=/path/to/file
    if [ -s ${transferfile} ]
    then
            ftp ${transferfile}
    else
            echo ${transferfile} is empty.
    fi

    ##
    Its all in using the `[` command. Yep, never forget, `[` is just an other name
    for the command `test`. You can see `man test` for all options they accept and
    use them with the `[` in `if`, `while` and such.

    CBee

    >
    > ------------------------------------------------------------------------
    > *De :* hpux-admin-owner@DutchWorks.nl
    > [mailto:hpux-admin-owner@DutchWorks.nl] *De la part de* Balaji Nathan
    > *Envoyé :* mercredi 11 mai 2005 22:24
    > *À :* hpux-admin@DutchWorks.nl
    > *Objet :* [HPADM] help with a script - condition to check the size of
    > the file and initiate ftp
    >
    > Hi admins,
    > Please help me on the following:
    > I have to set up a condition;
    >
    > ie if the file "testxx" is zero bytes, DO NOT iniate the ftp process.
    > If "testxx" size is other than zero byte, initiate the ftp.
    >
    > Please help me on the script syntax..
    > Thanks
    > Balaji
    >
    > ------------------------------------------------------------------------
    > Do you Yahoo!?
    > Yahoo! Small Business - Try our new resources site!
    > <http://us.rd.yahoo.com/evt=31637/*http://smallbusiness.yahoo.com/resources/>
    >

    --
                 ---> Please post QUESTIONS and SUMMARIES only!! <---
            To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
           Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
     
     Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
                http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)
    

  • Next message: Kasula, Sridhar Rao: "[HPADM] directory size limit..."

    Relevant Pages

    • Re: [SLE] YAST Online Update error: kdesu: cannot connect to X server
      ... My SGI Prism running SLES 9 is also very temperament ... > online_update') from command line it should bring up ... > Do You Yahoo!? ... Mail has the best spam ...
      (SuSE)
    • SUMMARY: cropping a file
      ... Although this will execute very quickly (assuming ... The logfile is being modified by two ... he executes the 'w' command. ... > Do you Yahoo!? ...
      (Tru64-UNIX-Managers)
    • Re: [SLE] wav => mp3 w/ Audacity
      ... In poking around the web I discovered that the latest ... features so I downloaded the 1.2.0 version and ... > with lame directly with the command: ... Do you Yahoo!? ...
      (SuSE)
    • Re: Hidden Folders
      ... Subject: Hidden Folders ... > have open shares, as people could hide files in your ... command, or do searches for files that have the hidden ... Get email alerts & NEW webcam video instant messaging with Yahoo! ...
      (Vuln-Dev)
    • Re: General question about HTML form
      ... > You run the program from the command line to make ... > <!DOCTYPE html ... Do you Yahoo!? ... Finance Tax Center - File online. ...
      (perl.beginners)