I am very new to coding/scripting..

I have a noob question I guess:

I have this script to upload and delete files on my remote host:


echo Starting Website upload ...
echo This may take some time depending on your internet connection ...
echo Waiting for remote connnection ...

/usr/bin/ftp -d server121.web-hosting.com << ftpEOF

    cd public_html
    delete index.html
    cd images
    mdelete *.jpg
    cd ..    
    lcd /Applications/PlexEmail/streamnet/
    put index.html
    lcd images
    cd images
    mput *.jpg

echo Website upload successfull ...

Ok so now I upgraded my mac to high sierra 10.13 and there is no ftp command anymore.

Can please someone help me out to get this to work with lftp?

  • lftp is not part of the standard install, what is this? And if you are open for additional software installs, why not just install ftp via homebrew? – nohillside Oct 1 '17 at 7:39
  • Ftp isnt compiled for os high sierra via homebrew, thats why i installed lftp via homebrew, i think i is the same but it isnt:( – Cyb3rGh05t Oct 1 '17 at 7:48

From looking at the lftp man page it seems as if lftp is scriptable. Something like the following should work (untested):

# upload script (save as website-update.lftp)
open server121.web-hosting.com
cd public_html
lcd /Applications/PlexEmail/streamnet/
put index.html
cd images
lcd images
mrm *.jpg
mput *.jpg

And then use

lftp -f website-update.lftp

to execute it.

PS: lftp also has a mirror command which would this make even easier, probably.

  • 1
    Thank u very much patrix. I just started learning coding so sorry for that noib question:/ i will try it out. Thank you – Cyb3rGh05t Oct 1 '17 at 10:19
  • Does it takes the username and password for the remote host from the .netric file for ftp or do i need to add something else? – Cyb3rGh05t Oct 1 '17 at 10:30
  • @IveFlammang According to the man page it should read .netrc. There is no harm in trying this, actually just using lftp server121.web-hosting.com should get you logged in. – nohillside Oct 1 '17 at 10:32
  • Thank you @patrix thats very helpfull. These days its hard to find helpfull poeple. Thanks – Cyb3rGh05t Oct 1 '17 at 10:39
  • do you know how i can add this into a Launchagent? – Cyb3rGh05t Oct 1 '17 at 18:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .