[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
- Previous message: Bryan.Quinn_at_CooperTools.com: "[HPADM] Chinese Locale for HPUX 11.0"
- In reply to: BAKHSHESH Kazem: "[HPADM] RE: help with a script - condition to check the size of t he file and initiate ftp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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)
- Previous message: Bryan.Quinn_at_CooperTools.com: "[HPADM] Chinese Locale for HPUX 11.0"
- In reply to: BAKHSHESH Kazem: "[HPADM] RE: help with a script - condition to check the size of t he file and initiate ftp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|