Results 1 to 6 of 6

Thread: best way to ftp one file and schedule?

  1. #1
    Join Date
    Oct 2005
    Location
    sweden-solna
    Beans
    93
    Distro
    Ubuntu 8.04 Hardy Heron

    best way to ftp one file and schedule?

    Hi I want to ftp one file for example each hour so its a easy task.
    Best application and way to achive it?

    Thanks in advance
    /J
    dell 4100, hp6910p, popcorn hour,nslu2

  2. #2
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: best way to ftp one file and schedule?

    I'd use cron and scp

  3. #3
    Join Date
    Oct 2005
    Location
    sweden-solna
    Beans
    93
    Distro
    Ubuntu 8.04 Hardy Heron

    Question Re: best way to ftp one file and schedule?

    Quote Originally Posted by hyper_ch View Post
    I'd use cron and scp
    Ok I found a script to use ftp the file and it works when I
    go to the directory where it is adn simply click it.

    Then I did sudo crontab -e and putted this in crontab (I think its roots crontab?):

    */10 * * * * root /home/janne/folder/ftp.sh

    I did chmod 775 to ftp.sh.

    But it dont upload with crontabs help as I indeed hoped.
    dell 4100, hp6910p, popcorn hour,nslu2

  4. #4
    Join Date
    Oct 2007
    Location
    United Kingdom
    Beans
    762
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: best way to ftp one file and schedule?

    Without knowing what's in ftp.sh it's going to be very hard to help you. Personally, if the target machine also has ssh, I would also recommend using scp instead of ftp.
    "Python, the language that wraps itself around a problem to squeeze out a solution, swallowing it whole."
    Linux user number #14284
    "A journey of a thousand miles begins with a single step." - Confucius.

  5. #5
    Join Date
    Oct 2005
    Location
    sweden-solna
    Beans
    93
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: best way to ftp one file and schedule?

    Quote Originally Posted by ByteJuggler View Post
    Without knowing what's in ftp.sh it's going to be very hard to help you. Personally, if the target machine also has ssh, I would also recommend using scp instead of ftp.
    host ftp.somehost
    user a-user
    passwd ****

    FILE:snapshot.jpg
    #the file is in same directory

    ftp -n $HOST <<END script
    quote user $USER
    PUT $FILE
    END SCRIPT
    exit 0

    I can run it with ./ftp.sh when in that folder.
    tested it again and it works.

    so how can I do the same with crontab?
    dell 4100, hp6910p, popcorn hour,nslu2

  6. #6
    Join Date
    Oct 2007
    Location
    United Kingdom
    Beans
    762
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: best way to ftp one file and schedule?

    Quote Originally Posted by janne5011 View Post
    host ftp.somehost
    user a-user
    passwd ****

    FILE:snapshot.jpg
    #the file is in same directory

    ftp -n $HOST <<END script
    quote user $USER
    PUT $FILE
    END SCRIPT
    exit 0

    I can run it with ./ftp.sh when in that folder.
    tested it again and it works.

    so how can I do the same with crontab?
    Please use code and quote tags to delimited quoted code etc. Are you saying your file, "ftp.sh" contains exactly:

    Code:
    host  ftp.somehost
    user a-user
    passwd ****
    
    FILE:snapshot.jpg
    #the file is in same directory
    
    ftp -n $HOST <<END script
    quote user $USER
    PUT $FILE
    END SCRIPT
    exit 0
    If so, that's not a valid shell script, for one it lacks the proper headers to identify it as a shell script. Secondly, am I right in thinking you have a file called "END" that contains an EOF character or something?

    Anyway, things you need to address:
    1.) Headers (Put "#!/bin/bash on the first line)
    2.) Working directory. The script might work when your working directory is your home folder or wherever, but the working directory is almost certainly not that when cron runs it. You need to put some "cd" commands in to change the folder appropriately, or specify explicit paths.
    3.) Access rights Make sure cron will have rights to the folder/file in order to be able to ftp it.
    4.) Also, your "shell script" seems to be a mixture of input for the "ftp" command and shell commands. You should not leave the input to "ftp" in the shell script itself, put that in a seperate file instead, and pipe that into ftp. E.g. "ftp -n $HOST <ftp_input" Edit: Never mind, I see how "END_SCRIPT" works to allow you to intersperse input to ftp with shell script code.

    Edit2: Here's a good example of a shell script involving ftp'ing.
    Last edited by ByteJuggler; June 27th, 2008 at 12:36 PM.
    "Python, the language that wraps itself around a problem to squeeze out a solution, swallowing it whole."
    Linux user number #14284
    "A journey of a thousand miles begins with a single step." - Confucius.

Bookmarks

Posting Permissions

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