Operating System - HP-UX
1838671 Members
6446 Online
110128 Solutions
New Discussion

help with script..ftp script

 
amonamon
Regular Advisor

help with script..ftp script

Hello I was doing some script but I simply can not get it work..
basicly on machineA script1 to execute every 15 min.

script1 should check for files in machineB in /path/machB
if there are files on machine2 take them on machineA /path/machA and remove files in folder /path/machB on machine B.

any help is usefull..

regards
15 REPLIES 15
Ninad_1
Honored Contributor

Re: help with script..ftp script

Why not try rdist?
do a man rdist

Regards,
Ninad
Peter Godron
Honored Contributor

Re: help with script..ftp script

Hi,
easiest way to do this (in my opinion) is to set up a cronjob on machineA and use NFS exprted disk /path/machA.
That way all you have to do is cp the files from /path/machA to /path/machB.
amonamon
Regular Advisor

Re: help with script..ftp script

I woulg like to u that with mget command...I did something with that...but it does not work OK..

to execute it basicly from machineA do mget files ftom filder on machineB and remove all files in that folder on machineB

can U please start with code..I would like to see how to start..
later I did script which parses those files..

regards..
amonamon
Regular Advisor

Re: help with script..ftp script

OK i should maybe post what I did so far...

ftp -i -n <> logFTP
open Bmachine_IP_address
user BmachUSER BmachPASS
cd /Bmach/folder
prompt
mget 12*
#delete anes*
quit
EOF


But removing files on remote machine does not work...how can I remove them..delete does not seems to do a job for me..
amonamon
Regular Advisor

Re: help with script..ftp script

OK i should maybe post what I did so far...

ftp -i -n <> logFTP
open Bmachine_IP_address
user BmachUSER BmachPASS
cd /Bmach/folder
prompt
mget 12*
#delete 12*
quit
EOF


But removing files on remote machine does not work...how can I remove them..delete does not seems to do a job for me..
Marvin Strong
Honored Contributor

Re: help with script..ftp script

my advice would be to use scp, then you have a secure connection, and transfer. And its easy to setup.

Prasanth B
Trusted Contributor

Re: help with script..ftp script

Hi,

Would it be possible for you to push files from machine B rather than pulling from Machine A. So instead of mget, use mput from Machine B and in your scriot after EOF generates a list of files using `ls -1` and delete them all
-PB
Take life as it comes
IT_2007
Honored Contributor

Re: help with script..ftp script

Reason for not able to delete files on the remote machine is you don't have permission to delete them. Change permissions for files on the remote machine and execute.
amonamon
Regular Advisor

Re: help with script..ftp script

I know Prasanth B U have right but I can not allow machineB to have acces and to do mput..

If U could help me out with that I would love...
also delete does not work even if I change premissions on file to 777..

Any ideas?
IT_2007
Honored Contributor

Re: help with script..ftp script

Did you user to delete files. Check for the user permission who is doing ftp. It is like machineB having /test/file1 has 777 permissions and also check permissions for /test directory.
Peter Nikitka
Honored Contributor

Re: help with script..ftp script

Hi,

if the permissions are ok, you can delete files on the reomte host.
But looking at your ftp-commands, I see that you use a pattern to get multiple files - so you have to use 'mdel' to delete multiple files, not just 'del':
...
mget 12*
mdel anes*
...

mfG Peter

BTW: I would change to a ssh-connection, nevetheless, as many previous posters suggested.
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
amonamon
Regular Advisor

Re: help with script..ftp script

for some reason it does not work again...

mdel 22*

or even it would not remove single file with delete sommand..

Also I set premissions on remote file to 777..

any help??
Peter Nikitka
Honored Contributor

Re: help with script..ftp script

Hi,

the permissons on the file(s) are (nearly) meaningless - you have to check for the permission of the directory containing them!

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
amonamon
Regular Advisor

Re: help with script..ftp script

directory containing them is also 777.

thanks
Dave La Mar
Honored Contributor

Re: help with script..ftp script

Please check the following in yout /etc/ftpd/ftpaccess file -

# all the following default to "yes" for everybody
delete yes guest,anonymous # delete permission?
overwrite yes guest,anonymous # overwrite permission?


Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."