AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  Sent file text via FTP using cronjob

    Posted Tue March 10, 2009 06:29 AM

    Originally posted by: SystemAdmin


    Hi

    I have a similiar proble about to send text file to another machine,
    I want to send text file via FTP periodictly (run by cronjob)
    what is the command to do that ?
    I try to create sent_file.sh, and the script is :
    ftp -v -n 192.244.194.171 10021
    user Y32G801 PASI01
    mput /home/oradev/GARAP/temp/*.txt "$$ ID=Y120036 BID=GARAP text file XMIT=Y"
    bye

    but it did not work, anyone can help... ?

    Best regards
    #AIX-Forum


  • 2.  Re: Sent file text via FTP using cronjob

    Posted Tue March 10, 2009 06:46 AM

    Originally posted by: SystemAdmin


    My OS version IBM AIX 5.3
    #AIX-Forum


  • 3.  Re: Sent file text via FTP using cronjob

    Posted Wed March 18, 2009 11:28 PM

    Originally posted by: SystemAdmin


    Develop a shell script, in a secure directory, and make sure the permissions are 500 and ownership root:system. This means you can test it easily, and know that it will run. Testing in crontabs is a pain.

    I also prefer to use a here document for this type of thing; e.g.

    ftp -n host <<-EOF 1> /dev/null 2>&1
    user login password
    cd $dir
    put $ftpFile $asFile
    quit
    EOF

    The variables can then be setup in advance in the script.
    #AIX-Forum


  • 4.  Re: Sent file text via FTP using cronjob

    Posted Thu March 19, 2009 10:54 AM

    Originally posted by: MarkTaylor


    Using ftp is a security risk as it sends passwords in clearcase text, install and config sshd then you can use "scp" which is script friendly.

    HTH
    Mark Taylor
    #AIX-Forum


  • 5.  Re: Sent file text via FTP using cronjob

    Posted Fri March 20, 2009 04:28 AM

    Originally posted by: SystemAdmin


    hi Spook,

    thanks for the guide, but why this command doesn't work in IBM AIX ..?
    I try this command line
    ls -1 try.* > flist
    for i in `cat flist'
    do
    ftp -v -n ip_address <<z
    user user_name password
    put file_name "$$ ID=Y120036 BID='file_name' XMIT=Y"
    bye
    <x
    done

    the file in the ftp site will be $$ ID=Y120036 BID='file_name' XMIT=Y, the filename suppoed to be file_name

    do you have idea, why is this happen .. ?
    #AIX-Forum


  • 6.  Re: Sent file text via FTP using cronjob

    Posted Sat March 21, 2009 03:54 AM

    Originally posted by: SystemAdmin


    Hi,

    you tried to remove the spaces of the expression ?
    "$$ ID=Y120036 BID='file_name' XMIT=Y"

    and these $$ signs have a special meaning in the korn shell,
    (the PID process of this shell script).
    I recommend that you modify these signs by date, and don't forget
    put in the first line of the shell script:
    #!/usr/bin/ksh

    I hope that help you.
    Silvia.
    #AIX-Forum


  • 7.  Re: Sent file text via FTP using cronjob

    Posted Sun March 22, 2009 08:16 PM

    Originally posted by: SystemAdmin


    Silvia is right; use backslashes before each $ sign.
    e.g.
    put file_name "\$\$ ID=Y120036 BID='file_name' XMIT=Y"

    that will overcome the problems caused by the shell replacing $$ with the process ID.
    #AIX-Forum


  • 8.  Re: Sent file text via FTP using cronjob

    Posted Mon March 23, 2009 04:29 AM

    Originally posted by: SystemAdmin


    Hi Spook,

    this script from AIX system to windows system execute OK

    ftp -v -i -d -n 120.1.1.90 <<EOF
    user silvia silvia
    cd \/clientes\/tmp
    lcd /home/silvia/scripts
    put *.txt "$$ ID=silvia BID=prueba text file XMIT=Y"
    bye
    EOF

    the -d flag is for debug mode, help you to find errors.
    From AIX system to another AIX system executes OK too, but with
    cd /clientes/tmp
    #AIX-Forum


  • 9.  Re: Sent file text via FTP using cronjob

    Posted Mon April 06, 2009 11:28 AM

    Originally posted by: apple08


    Dear All,
    have u tried to mput files instead of put and once ftp successful for all the files, to remove the files. was thinking to upload weekly basis.
    hope to hear from you. you are very helpful. thank you
    #AIX-Forum


  • 10.  Re: Sent file text via FTP using cronjob

    Posted Tue April 07, 2009 04:32 AM

    Originally posted by: SystemAdmin


    You can use "mput" instead "put" in the cron script, but then if you want to delete the files from the source machine once a week you must add another cron script with the DANGEROUS sentence:

    find /directory -mtime +7 -exec rm {} \;

    Dangerous because this command removes files and you should check that do not delete important files on your machine. The find command with rm can have unexpected behavior that accidentally delete unwanted files.

    Before, test the behavior with:

    find /directory -mtime +7 -print

    and verify that it finds the desired files to delete.

    Regards
    Silvia.
    #AIX-Forum


  • 11.  Re: Sent file text via FTP using cronjob

    Posted Tue April 07, 2009 10:12 AM

    Originally posted by: nicofr


    Why don't you try to use scp ?

    More secure, because, by using FTP like this, first, all your credentials will be in clear text in the network and secondly, your username and password are stored in netrc file.

    Not secure at all ...
    #AIX-Forum