Operating System - HP-UX
1821984 Members
3396 Online
109638 Solutions
New Discussion юеВ

how to check the file size & FTP

 
SOLVED
Go to solution
vas  bolpali
Advisor

how to check the file size & FTP

1.how to create a file with 0 bytes size?

2.how to check the file size more than 10 bytes
to use that condition in a shell script ?

3. how to chage the permission of FTP files ?
i have a user 'ftpguy' . when ever 'ftpguy' try to write
files(using ftp process) on hp9000(HP-UX 11.0), the permission on the
created files always show as 'rw--r----' .
how to chage those permissions('rw-rw-rw') with in ftp script ?
keeping you ahead of the learning curve
10 REPLIES 10
Craig Rants
Honored Contributor
Solution

Re: how to check the file size & FTP

1.how to create a file with 0 bytes size?

# touch filename

2.how to check the file size more than 10 bytes
to use that condition in a shell script ?

SIZE=`ll filename | awk '{print $5}'`
if [ $RMSIZE -gt 0 ]
then
echo "Size is bigger that 0"
else
echo "Size is 0"
fi



3. how to chage the permission of FTP files ?
i have a user 'ftpguy' . when ever 'ftpguy' try to write
files(using ftp process) on hp9000(HP-UX 11.0), the permission on the
created files always show as 'rw--r----' .
how to chage those permissions('rw-rw-rw') with in ftp script ?

Use chmod option within ftp. You can read the man page to get all the info you want.

Good Luck,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Uday_S_Ankolekar
Honored Contributor

Re: how to check the file size & FTP

Hi,

You can create a 0 byte file by using touch command. touch filename

To find the file larger file

find /dir -size +10c -exec ls -l {} \;
where dir is the directory name. You can increase the number of zeroes infrint of 10 to llok for bigger files.

use chmod to change the permissions, you can use it within ftp itself or you can do it after ftp.

Goodluck,
-USA..
Good Luck..
S.K. Chan
Honored Contributor

Re: how to check the file size & FTP

for 3) you can set the umask for ftp users.
eg :
Change this line in /etc/inetd.conf from:
ftp stream tcp nowait root /etc/ftpd ftpd -l
to:
ftp stream tcp nowait root /etc/ftpd ftpd -l -u000

Files created by ftpd will have permissions of rw-rw-rw- unless there is a umask to alter the permissions.
By default the umask is 027 which
gives default permissions for files created by ftp as rw-r-----.

To re-read inetd.conf
# inetd -k => kill
# inetd => start it
A. Clay Stephenson
Acclaimed Contributor

Re: how to check the file size & FTP

Hi:

A very easy way to create a 0 length file is to use "cp /dev/null myfile".

The others have given you ways to determine file size.

You can also use the perl stat() function to get anything you want to know about a given file.
If it ain't broke, I can fix that.
Craig Rants
Honored Contributor

Re: how to check the file size & FTP

Oops,

if [ $RMSIZE -gt 0 ] should be

if [ $SIZE -gt 0 ]

Good thing I always double check my posts.

Sorry.
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Sanjay_6
Honored Contributor

Re: how to check the file size & FTP

Hi Vasu,

for question 1
# touch file_name

for option 2
SIZE=`ll filename | awk '{print $5}'`
if [ $SIZE -gt 10 ]
then
echo "Size is bigger that 0"
else
echo "Size is less than 10"
fi

For option 3,
use mask when ftp'ing the file, Here is a link on how to do that,
http://us-support2.external.hp.com/cki/bin/doc.pl/sid=91ec961512e2df8064/screen=ckiDisplayDocument?docId=200000051808646

Hope this helps.

Regds



Deshpande Prashant
Honored Contributor

Re: how to check the file size & FTP

HI
Use touch command to create a zero byte file.
Also "> file name" will create a null byte file.

For file permissions for ftp user either set the umask to 111 or use chmod command in ftp script.

Thanks.
Prashant.
Take it as it comes.
vas  bolpali
Advisor

Re: how to check the file size & FTP

Guys,
thnx all of you.
for my 3rd questions
i want to use chmod in FTP script.

here is my commands.
here i am using hp-ux ftp from hp3000 m/c.
it looks like chmod not a valid command in ftp.
or i am not using right syntax?



ftp
----
Name(manager): ftpuser
331 Password required for ftpuser.
Password:
230 User ftpuser logged in.
Remote system type is UNIX.
ftp> cd /u03/hp3000files/dc
250 CWD command successful.
ftp> put ACT052OZ.DATA zones.data
200 PORT command successful.
150 Opening ASCII mode data connection for zones.data.
226 Transfer complete.
2050 bytes sent in 0.00 seconds (400.39 Kbytes/sec)
ftp> chmod 777 zones.data
?Invalid command. (FTPERR 6)
ftp>
keeping you ahead of the learning curve
Gregory Fruth
Esteemed Contributor

Re: how to check the file size & FTP

The "chmod" command in the HP-UX FTP client
(i.e. "ftp") is a non-standard extension. It only works
if the FTP server understands the "SITE CHMOD"
command. The HP-UX FTP server (i.e. "ftpd")
does understand it, so that's why "chmod" in FTP
works when the client and the server are both
HP-UX. See the man pages for "ftp" and "ftpd"
for more info.

To see if the server supports "SITE CHMOD",
log into it with ftp, then type the command "site help"
at the ftp prompt and see what it says.

HTH
Magdi KAMAL
Respected Contributor

Re: how to check the file size & FTP

Hi Vasu,

1. Creating empty file ( size zero ) :
# touch emtyFile.log

2. Testing size if equal to 0 ( zero ) in a script :

if [[ `ls -l emptyFile.log ?? awk '{print $5}'` = 0 ]] then
echo "### emptyFile.log file size is ZERO ..."
else
echo "### emptyFile.log file size is NOT ZERO ..."
fi

3. Permission on file while ftp; You may set the umask ( File creation mask )value to allow that.

The following value 000 will give rwxrwxrwx for all files that will be created after.
# umask 000

The following value 111 will give r-xr-xr-x for all files that will be created after.
# umask 111

For some specific creation permissions, you may need to apply the following formula :

Needed permission = 666 - Mask-Value

Magdi