- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: FTP scripts check remote servers filesize with...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 01:47 AM
тАО03-01-2007 01:47 AM
FTP scripts check remote servers filesize with ftped files
I want to ftp the file in linux from windows server. After getting file in linux server i want to check the file size with windows(source) server. If the file size are same with linux then i want to erase the windows file remotely from linux server.
Can you please help me how can i write a
scripts to check file size with Win server and erase the same. I create a automated FTP scripts but i don't know how to incorporate the same in ftp scripts.
Thanks in advance.
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 02:01 AM
тАО03-01-2007 02:01 AM
Re: FTP scripts check remote servers filesize with ftped files
Checking the size of text files FTP'd between a Unix platform and a Windows platform will always yield a difference!
Unix uses a single character (linefeed) for delimiting newlines. Windows uses a linefeed *and* a carriage-return to denote the same. An Ascii mode FTP transfer will add or delete the carriage-return as necessary.
You need to interrogate the status of the FTP transfer. If successful, then issue a 'delete' command in your FTP session as you wish.
To determine whether or not your FTP commands are successful, you will need to parse the text messages from the session or use Perl. Checking the exit (return) status of an FTP session is meaningless as it will virtually always appear to have been successful.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 02:07 AM
тАО03-01-2007 02:07 AM
Re: FTP scripts check remote servers filesize with ftped files
Please see also:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 02:13 AM
тАО03-01-2007 02:13 AM
Re: FTP scripts check remote servers filesize with ftped files
you may be better off using NFS to mount the Windows directory onto the linux box.
You can then cp the file and check the cp return status.
if the return status is ok, remove the file from the nfs mount.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 02:53 AM
тАО03-01-2007 02:53 AM
Re: FTP scripts check remote servers filesize with ftped files
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 03:05 AM
тАО03-01-2007 03:05 AM
Re: FTP scripts check remote servers filesize with ftped files
Thanks for your valuable info. Can you please somebody help me how to add check status and delete command in the following shell scripts.
following scripts ftp file from windows to linux and it residing in linux server.
#!/bin/bash
ftp -n -i
user
dir
mget *
bye
EOF
exit
Thankx
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 03:48 AM
тАО03-01-2007 03:48 AM
Re: FTP scripts check remote servers filesize with ftped files
The attached Perl script returns 0 if ok and non-zero if bad and that's all you need to know to make this work. I will invoke the script one time to get the files in the remote directory and then invoke again for each to get and delete each file. It only deletes the remote file, if the get was ok.
#!/usr/bin/sh
typeset remhost="bugs"
typeset user="cstephen"
typeset passwd="secret"
typeset remdir="/tmp/acs" # remote directory
typeset FNAME=""
typeset -i STAT=0
ftpget.pl -h ${remhost} -l ${user} \
-p ${passwd} -d ${remdir} -L "" |\
while read FNAME
do
echo "Getting ${FNAME}"
ftpget.pl -h ${remhost} -l ${user} \
-p ${passwd} -d ${remdir} -B -r "${FNAME}"
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Get of \"${FNAME}\" failed; status ${STAT}." >&2
break
fi
done
exit ${STAT}
The -B option asserts binary transfers; if you want ASCII use -A. It's important to quote the filename because you might have whitespace embedded in the pathnames --- especially on one of those evil Windows boxes. If you don't want to pass the password then put the username/password tuple in the .netrc file. Invoke as "ftpget.pl -u" for full usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2007 03:37 AM
тАО03-02-2007 03:37 AM
Re: FTP scripts check remote servers filesize with ftped files
Thanks for providing me perl scripts. I tried this scripts in my Linux server but it says "ftpget.pl" command not found. I think i have to installed perl in linux server.
Do you have any idea which commands work (from linux to windows)remotely to get a filenames from windows directory.
Thankx
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2007 03:44 AM
тАО03-02-2007 03:44 AM