- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ftp script
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
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
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
01-04-2002 12:48 PM
01-04-2002 12:48 PM
I am running a script in cron which check the dir, if the directory is empty the script exit otherwise start ftp, when the ftp done it will mv the files to done dir. Now what i want is that if the ftp connect drop by any reason it won't mv the files. But when the ftp session starts, I kill the session from the other service to check if its mv the files, and the script doing so, any suggestion.
Here's my script:
#!/bin/sh
cd /home/akhan/testdir
file=`find . -type f -print |wc -l`
if [ $file -eq 0 ]
then
exit 1
else
ftp -inv transrva <
bin
lcd /home/akhan
cd /home/akhan/ftp.sh
mput *
bye
EndFTP
fi
error_code=$?
if [ $error_code -eq 0 ]
then
filename=" "
for filename in `ls`
do
sleep 20
mv $filename /home/akhan/done$filename `date +%Y.%m.%d`
fi
Thanxs
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 12:55 PM
01-04-2002 12:55 PM
SolutionI posted a solution for this about a month ago. I the search function is cooperating today, I will try to dig-up the link to it and post it for you.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 01:02 PM
01-04-2002 01:02 PM
Re: ftp script
Hi Adam:
In the past, I used to do this stuff in the shell but now I NEVER do because I have found a much cleaner way to do it that makes error trapping duck soup. Do this stuff in Perl using the Net::FTP module which is available from http://www.cpan.org .
Here's how simple it can be:
#!/usr/bin/perl -w
use Net::FTP;
use strict;
my $ftp = Net::FTP->new("remotehost",Debug => 0);
$ftp->login("cstephen","top_secret");
$ftp->cwd("/tmp");
$ftp->get("myfile");
my $stat = $ftp->status;
my $full_stat = $ftp->code;
# $stat contains the first digit; usually all
# that you need to do is test if it is equal
# to 2. $full_stat contains the full 3-digit
# value but is seldom needed
printf("Status: %d Full Status: %d\n",$stat,$full_stat);
# Sample Test
if ($stat == 2)
{
print "Get was good\n";
}
else
{
print "Get was bad\n";
}
$ftp->quit;
I think if you start using this module you will never go back to shell scripting FTP. Moreover, these same scripts will run in the NT world.
Notice that this method easily handles the error checking. If you like, you can use the shell for most of your script and simply use a bit a perl for the actual FTP transfers. In that case add the statement exit($stat) to the perl script and then your shell script does have a valid status indication.
Now, if it were me I would do it all in Perl but that's just my blind and simple approach.
Food for thought, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 01:06 PM
01-04-2002 01:06 PM
Re: ftp script
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 01:24 PM
01-04-2002 01:24 PM
Re: ftp script
Also, once having copied the file, use sum -r to do a checksum, and compare it with the checksum on the source. This ensures that your file arrived intact--regardless of how long it took to copy or how many errors were encountered along the way.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2002 06:08 PM
01-04-2002 06:08 PM
Re: ftp script
you could use "scp" instead of "ftp" or "rcp" to be on the save side...
But for your "ftp" scripting, why not do this on the client side:
Move that "mv" command into your list of "ftp" commands using the "!" (bang) notation - if your "ftp" is broken, htat "mv" will NOT be executed!
HTH,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2002 06:13 AM
01-07-2002 06:13 AM
Re: ftp script
I agree with you, but the thing is that we getting the file from differen banks to process, so banks are ftp the files in ftp server.
Anyway thanxs guys for ur help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2002 06:47 PM
01-23-2002 06:47 PM
Re: ftp script
Banks are using FTP?! *faint on the spot* This forum is not for the faint-hearted.
Which bank is that? I won't want to deposit money in such a bank :P
FTP transmits data in the clear and is vulnerable to spoofing, hijacking and data sniffing attacks to name just a few.
Why are you still using FTP?
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2002 07:24 PM
01-23-2002 07:24 PM
Re: ftp script
I was a developer for a bank and then a banking software company (specializing in ATM's, ACH, EDI, Teller Terminals, Check Sorters, data file transmissions, and yes, unix) for almost 10 years, and that's where I TAUGHT other banks, the IRS, state agencies, and other vendors HOW data was to be transmitted.
Steven, What Anthony is using is a semi-secure private network within the financial community, probably something I'll be using soon. The network really isn't BankA sending data directly to BankB, what happens is that BankA sends their data to a REPOSITORY (some call it a mail box), where then BankB can go get it. Only BankA can see BankA's "private" network, and the same is true for everyone else. Now I agree that if you have not encrypted your data, that you run the risk of hijacking, and if I was the developer, I'd be slapping people into shape that, yes the data would be encrypted. But, hell, a few years ago, I could have created an ACH tape, and sent it to almost any bank and it would have been processed. Fortunately, things have changed, and security in banks is getting better, but I'm sure I could empty most ATM's with very little work: wire cutters, a PC, some extra wire, and a lot of stupidity (it's a federal crime!).
live free or die
harry