Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I want to write a shell script to achieve the following Local server - IP 192.168.10.20 - FTP script running in this server - Log files location: /logs/omni_logs/fullcdr/ - ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie amithad's Avatar
    Join Date
    Sep 2006
    Location
    Sri Lanka
    Posts
    160

    Lightbulb Shell Script to Transfer Files ( FTP)


    Hi,

    I want to write a shell script to achieve the following

    Local server

    - IP 192.168.10.20
    - FTP script running in this server
    - Log files location: /logs/omni_logs/fullcdr/
    - Log files name: [yymmdd][seq_no]_WN_03_FULL_LOG (eg-12110101_WN_03_FULL_LOG)

    Remote Server

    - IP 192.170.10.10
    - User name: ftpuser, Password: mytest
    - Log transfer location: /logs/ftp_log/
    - Log files name: [yymmdd][seq_no]_WN_03_FULL_LOG

    Conditions

    - There should be a single retry attempt in 20 seconds for ftp connect if first attempt is failed
    - Transfer all files in local location which have no extension “.sent” to remote location
    - Check whether files have transferred completely and files are available in remote location
    - Rename transferred files in local location with “.sent” as extension so next time script will not attempt
    to transfer already transferred files.

    I have written a script partly but need corrections and enhancements or a totally different script. Could you assist me pls?

    My Script
    Code:
    #!/bin/bash
    
    
    ftp -u ftpuser -p mytest ftp://192.170.10.10/logs/ftp_log < /logs/omni_logs/fullcdr/*[LOG$]
    
    cd /logs/omni_logs/fullcdr
    
    mv *[LOG$]  /logs/omni_logs/fullcdr/*[LOG$].sent

  2. #2
    Linux Newbie
    Join Date
    Nov 2012
    Posts
    224
    hi,

    didn't you ever connect to a ftp server?

    ftp connection are not the same as if you logged on a machine.
    ftp commands are not the shell commands, when connected type in ?
    (question mark) so every command available will be printed on screen.

    I suggest you do more research about how work ftp and "ftp scripts".

  3. #3
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    174
    If you can switch to using "scp" instead, you'll be much, much happier. It's better suited to the sort of task you seem to have in mind. Is that an option?

    Also, if those are the real ip, user and password then you should change the password. While people on this site are by and large well intentioned folks, it's really a bad idea to post a working user/password combo to a public forum.
    Last edited by cnamejj; 11-25-2012 at 09:04 AM. Reason: Additional suggestion added, warning about posting user/password info...

  4. #4
    Linux Newbie amithad's Avatar
    Join Date
    Sep 2006
    Location
    Sri Lanka
    Posts
    160
    Quote Originally Posted by cnamejj View Post
    If you can switch to using "scp" instead, you'll be much, much happier. It's better suited to the sort of task you seem to have in mind. Is that an option?

    Also, if those are the real ip, user and password then you should change the password. While people on this site are by and large well intentioned folks, it's really a bad idea to post a working user/password combo to a public forum.

    Dear cnamejj,

    I have to use FTP no other option. These passwords are ok hence this FTP site is hosted internally. You are correct I should not divulge any authentication info in a public forum

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •