How to ftp, scp or mail from Cron to web

Discussion in 'Mac Programming' started by donnist, Oct 1, 2012.

  1. donnist macrumors newbie

    Joined:
    May 13, 2009
    #1
    I am trying to send logs stored on my mac at home to my webpage so they can be viewed online. I want it to be done via cron jobs. Most of the solution I found only works on Linux boxes. Thanks in advance! :apple:
     
  2. kryten2, Oct 1, 2012
    Last edited: Oct 1, 2012

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    Can you give an example of such a solution or a link? If you want to use cron it's there for you to use.
     

    Attached Files:

  3. donnist, Oct 1, 2012
    Last edited by a moderator: Oct 1, 2012

    donnist thread starter macrumors newbie

    Joined:
    May 13, 2009
    #3
    I found a cron job that runs a shell script...

    Thanks Kryten2

    I found a cron job that runs a shell script... this is sort of what I am looking for but how would it be done via scp or email. I just want to find the most simplest way possible.


    Here is the example:
    ################################################
    #
    Code:
    crontab -e
    1 17 * * * "/usr/bin/lftp -c "open $hostname && user $username $password && cd $current_dir && get -c $file_name"
    
    
    #!/bin/ksh
    
    sdir="/var/mqm/tmp/pso/"
    filename="pso_whse_orders_inout"
    hostname="n0aif01"
    username="evaxd4"
    password="march2012"
    
    ftp -in $hostname <<EOF
    user $username $password
    
    binary
    cd $sdir
    get $filename /location/to/localfile
    quit
    EOF
    
    mv -f $filename $filename.`date '+%Y%m%d'`
    ################################################
     
  4. kryten2, Oct 1, 2012
    Last edited: Oct 1, 2012

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
    If you want it to be done via cron jobs you'll have to write a script. If you're not comfortable with writing scripts or adapting the ones you find on the net to your needs, you might want to take a look at Automator.

    Automator email ex :

    1. Get Specified Finder Items
    2. New Mail Message
    3. Save as iCal Alarm plugin (This has changed on SL, Lion and ML)

    Automator scp ex :

    Uploading files using SCP with an Automator Service info : http://www.rmacd.com/code/2011/1127/1715.html
    Using the Upload with SCP action from Automatorworld : http://automatorworld.com/archives/upload-with-scp/

    Note: both use public/private-key authentication!
     
  5. donnist thread starter macrumors newbie

    Joined:
    May 13, 2009

Share This Page