Skip to content

Instantly share code, notes, and snippets.

@meetme2meat
Forked from pandurang90/netcat.scpt
Created January 22, 2014 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meetme2meat/8557085 to your computer and use it in GitHub Desktop.
Save meetme2meat/8557085 to your computer and use it in GitHub Desktop.
tell application "SystemUIServer"
set actionSelected to the button returned of (display dialog "What you want to do?" buttons {"Send file", "Receive file"} default button 2)
if actionSelected = "Send file" then
set filepath to POSIX path of (choose file)
display dialog "Please enter IP address of receiver:" default answer ""
set ipAddress to text returned of result
if ipAddress = "" then
repeat
display dialog "IP address cant be blank,Please enter IP address of receiver:" default answer ""
set ipAddress to text returned of result
if ipAddress is not equal to "" then exit repeat
end repeat
end if
else
display dialog "Please enter a file name with extension:" default answer ""
set filename to text returned of result
if filename = "" then
repeat
display dialog "Filename cant be blank,Please enter a file name with extension:" default answer ""
set filename to text returned of result
if filename is not equal to "" then exit repeat
end repeat
end if
end if
display dialog "Please enter a port number ,must be integer:" default answer ""
set portnumber to text returned of result
if portnumber = "" then
repeat
display dialog "Port number cant be blank, Please enter a port number, must be integer:" default answer ""
set portnumber to text returned of result
if portnumber is not equal to "" then exit repeat
end repeat
end if
display dialog actionSelected
if actionSelected = "Send file" then
display dialog "Sending"
do shell script "nc " & ipAddress & " " & portnumber & " < " & filepath & " -"
"sending"
else
display dialog "Receiving"
do shell script "nc -l " & portnumber & " > " & filename
"receiving"
end if
end tell
@estockly
Copy link

I don't think this works for me. In what directory should the file appear on the remote machine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment