2

I have a problem with a script that I am trying to write.

Ideally, the script should compress the folders and then send the zipped files to the ftp server creating the folder as the name of the zipped file (without extension) but it's not working correctly quite yet, what am I doing wrong ?

Hi, the manually executed script returns this error

mirror: Access failed: 530 Access denied (.zip)

I would like to send the files that zipped to the ftp server, what should I change? Thank you

#!/bin/sh
HOST=""
USER=""
PWD=""
FILESIZE="$(du -sm $1 | cut -f1)"
ZIPNAME="$(basename $1)"
REMOTEFOLDER="$(dirname $1)"

if [ $FILESIZE -ge 1500 ]
then
        7z a -v1400m $REMOTEFOLDER/$ZIPNAME.zip $1
else
        7z a $REMOTEFOLDER/$ZIPNAME.zip $1
fi

lftp ftp://$USER:$PWD@$HOST -e "set ssl:verify-certificate no; mirror -R -r -i '$ZIPNAME.zip*' $REMOTEFOLDER /$REMOTEFOLDER; quit"
  • Hello and welcome to unix.se! Impressive first question, too, but it's still missing a few things. You've explained what you want your script to accomplish pretty well, but what you haven't mentioned is what's actually happening and in which way it's failing. Does the lftp command return any errors? What happens differently if you attempt to run the lftp part manually instead? – Shadur Oct 16 '18 at 9:28
  • (We can discuss lftp bookmarks, saved passwords and the extreme inadvisability of using passwords on a command line visible with ps axe at a later date as it's probably not germane to the reason why your script isn't working. – Shadur Oct 16 '18 at 9:29
  • Hi, the manually executed script returns this error mirror: Access failed: 530 Access denied (.zip) – Peppe J Oct 16 '18 at 9:34
  • Please add that to the question proper rather than comments. It looks like it's not generating the filenames properly because it refuses to let you mirror a file named ".zip" which probably isn't what you wanted to happen... – Shadur Oct 16 '18 at 9:35
  • Another thing you can try is running the script with sh -x. This will echo each command before it's executed, and may help catch quoting errors. Perhaps what you think it's sending isn't quite what's going on. – Shadur Oct 16 '18 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.