Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: SSH and script weirdness #371709
    philsto
    Participant

    Yeah, it looks like it…. We’ll try that, thanks.

    Phil

    in reply to: SSH and script weirdness #371704
    philsto
    Participant

    Hey there,

    It’s our understanding that –N option on wget just tells it to continue saving the file in the same spot, otherwise, if you download the same file to a directory twice, regardless of whether you have deleted the original, it will name the new one “filename.1”. This would make it difficult to write a script for, since the file name would constantly be changing.

    Is that a misunderstanding of the function, or does it have some other effect which may have gotten in the way?

    Phil

    in reply to: SSH and script weirdness #371687
    philsto
    Participant

    Here is the script….

    My misunderstanding, the script does not require root under ssh. it runs fine as any user. However, it also creates 0 Kb files when initiated from terminal on the server itself…
    #!/bin/bash

    HOST_IP=0.0.0.0
    IMAGE_URL=http://0.0.0.0/jpg/1/image.jpg
    IMAGE_DIR=/Volumes/Data/Webserver/File
    W_DIR=/scripts
    SLEEP_TIME=30
    HOST_REACHABLE=1

    grab()
    {

    D=`date +%F%p`

    echo “Checking the server.”

    ping -c 1 $HOST_IP &> /dev/null

    if [ $? = 0 ]; then
    HOST_REACHABLE=1

    echo “Getting image file.”

    /opt/local/bin/wget -N $IMAGE_URL > $W_DIR/image.jpg

    if [ $? = 0 ]; then
    echo “Archiving…”
    mv $W_DIR/current.jpg $W_DIR/bak/image.$D.jpg
    if [ ! -s $W_DIR/image.$D.jpg.gz ];
    then gzip -c $W_DIR/bak/image.$D.jpg > $W_DIR/bak/image.$D.jpg.gz
    fi
    rm $W_DIR/bak/image.$D.jpg
    echo “Updating..”
    mv $W_DIR/image.jpg $W_DIR/current.jpg
    ditto $W_DIR/current.jpg $IMAGE_DIR/current.jpg
    echo “Done.”
    else
    echo “Error: Image Not Found”
    HOST_REACHABLE=0
    fi

    else
    echo “Error: Host Unreachable”
    HOST_REACHABLE=0
    fi
    }

    while [ $HOST_REACHABLE = 1 ]; do
    grab
    echo “Sleeping…”
    sleep $SLEEP_TIME
    done

    exit 0

Viewing 3 posts - 1 through 3 (of 3 total)