Bash script running on my MBP 10.7.4 but not on other Macs (all 10.7.4)
A friend of mine wrote me this short script to run in terminal that downloads a particular file every n seconds from a password protectected FTP site. The script worked on his linux machine and on my Mac but not on my collegues Macs. I'm wondering if anybody knows reasons why it may be failing on other Macs.
We changing the first line from: #!/bin/sh to #!/bin/bash
and exceuting with
user_prompt_$ bash ./download_stats.sh
Another idea is to script cyberduck but it doesn't support applescript though may have a comand line interface (looking into that at present).
There error output from one of the accounts it fails on follows the script listing.
#!/bin/sh
#
# =================================================================
# Download XML_stats Bash Script
#
# Filename: download_stats.sh
# Arguments: input_filename - file to be downloaded from remote server. Optional.
# poll_interval - seconds delay between downloads. Optional (input_filename must be present)
# Use: Invoke from shell, e.g. ./download_stats.sh
# Author: Luke Neeson
# Date Created: 2012-05-31
# Comments: This script will download a given file, input_filename, at the given interval, poll_interval.
# Notes:
# - .netrc is required in the current directory and must contain the logon details for the fox server. This could be installed in the user home directory, if so, delete the line marked below.
# =================================================================
# If the .netrc is in the directory of this script, the following must be enabled. If the user's home .netrc is to be used, comment out the following line:
export HOME="`pwd`"
export input_filename="the_file_I_want_as_default.xml"
export poll_interval=10
if [ ! -z "$1" ] ; then
export input_filename="$1"
if [ ! -z "$2" ] ; then
export poll_interval="$2"
fi
fi
while [ true ]
do
ftp access.foxsports.com.au << EOF 2>&1 | sed 's/.*AUTH GSSAPI.*//g' | sed 's/.*KERBEROS.*//g'
get "$input_filename"
quit
EOF
sleep $poll_interval
done
ERRORS RETURNED:
a-mbp:~ macca$
a-mbp:~ macca$ cd ~/stats/download_rugby_stats/
a-mbp:download_stats a$ sh download_rugby_stats.sh
: command not founds.sh: line 16:
: command not founds.sh: line 19:
: command not founds.sh: line 22:
download_stats.sh: line 39: syntax error: unexpected end of file
a-mbp:download_stats a$
Those are the blank lines and 39 is the last line of script.
MacBook Pro, Mac OS X (10.7.3), 10.7.4 actually Wacom 6x11