Reputation: 313
I'm using the lrzsz tool to transfer files between a Mac and a Linux server. Using sz works fine, but when I use rz in the Linux terminal for the first time, it opens the Mac file upload UI. After the first selection, the upload UI keeps opening multiple times, even if I cancel subsequent pop-ups. The file uploads correctly to the server selected the first time.
The main issue is why it keeps asking to upload a file after the first selection.
Here is the rz file trigger set in Mac:
#!/bin/bash
# Author: Matt Mastracci ([email protected])
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domain
osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
else
FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
fi
if [[ $FILE = "" ]]; then
echo Cancelled.
# Send ZModem cancel
echo -e \\x18\\x18\\x18\\x18\\x18
sleep 1
echo
echo \# Cancelled transfer
else
/usr/local/bin/sz "$FILE" -e -b
sleep 1
echo
echo \# Received $FILE
fi
I attempted to inspect the script file for any loop events that could trigger multiple file upload actions but couldn't find any.
Upvotes: 0
Views: 325
Reputation: 61
You state that you are having problems with rz, but your rz file trigger calls /usr/local/bin/sz
rather than /usr/local/bin/rz
. I assume that the other side is sending more requests to send when it does not get a response that it expects, leading to the multiple pop-ups.
However, it is hard to say what is happening from the information you provided. For instance, you do not mention that you are using iTerm in your question, and this is fundamentally an iTerm configuration issue. Make sure you carefully follow the instructions that you are using for this procedure, install both file triggers, and point iTerm to the appropriate one for download or upload.
By the way, gnu screen is very easy to configure to use zmodem with lrzsz and it is built into your Mac! You don't need iTerm2 and these extra AppleScript files.
Upvotes: 0