cannot execute binary file

I’m completely new to this.

When cron runs my script I’m getting
/bin/sh: /Library/Scripts/User/GetIP.scpt: cannot execute binary file

This is my script
set my_externalIP to do shell script “curl http://whatismyip.org
set d to current date
set s to (d as string)
set f to (“/ip.txt”)
set ref_num to open for access f with write permission
set eof of ref_num to 0
write s & " - " & my_externalIP to ref_num
close access ref_num

I think the error means that I haven’t provided a translator in the script, but I’m not sure how I would go about doing this.

Any help gratefully received, thanks.

Hi,

cron can only run shell scripts. Use osacscript to run the AppleScript

/usr/bin/osascript /Library/Scripts/User/GetIP.scpt

Thanks very much. I put that script into my crontab and it seems to be working.

I’d like to copy the file to another folder too

I’ve tried

set my_externalIP to do shell script "curl http://whatismyip.org"
set d to current date
set s to (d as string)
set f to ("/ip.txt")
set id to ("~/Desktop/ip.txt")
set ref_num to open for access f with write permission
set eof of ref_num to 0
write s & " - " & my_externalIP to ref_num
close access ref_num

tell application "Finder"	
	copy file f to d
end tell

but I get

error “Can’t set id to "~/Desktop/ip.txt".” number -10006 from id

I think I could use something like

#!/bin/sh
#Script name: cpid
cp /ip.txt ~/ip.txt
but I think this would be a shell script? and 1) not sure how to save it 2) not sure how to then include it in the above script.

I’m running snow leopard and have the developer tools installed.

Again, any help is appreciated, thanks.

variable names with one letter are very badly readable and can cause terminology clashes.
In your case id is a reserved word.

Another problem:
the Finder expects HFS paths (starting with a disk name and colon separated)

try this:

set my_externalIP to do shell script "curl http://whatismyip.org"
set currentDate to current date
set dateString to (currentDate as string)
set ipFile to ("/ip.txt")
set desktopLocation to POSIX path of (path to desktop) & ("ip.txt")
set ref_num to open for access ipFile with write permission
set eof of ref_num to 0
write dateString & " - " & my_externalIP to ref_num
close access ref_num
do shell script "bin/cp " & quoted form of ipFile & space & quoted form of desktopLocation

Of course, I should have picked up on that, thanks.