3

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:

#!/bin/bash

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

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

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?

nohillside
  • 100,768
  • 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 01 '17 at 07: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 01 '17 at 07:48
  • See https://apple.stackexchange.com/questions/299758/how-to-get-bsd-ftp-and-telnet-back-in-10-13-high-sierra – nohillside Oct 01 '17 at 08:31

1 Answers1

2

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
exit

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.

nohillside
  • 100,768
  • 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 01 '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 01 '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 01 '17 at 10:32
  • Thank you @patrix thats very helpfull. These days its hard to find helpfull poeple. Thanks – cyb3rgh05t Oct 01 '17 at 10:39
  • do you know how i can add this into a Launchagent? – cyb3rgh05t Oct 01 '17 at 18:40
  • @user3901913 If you have a different question, feel free to ask it using the Ask Question button at the top right. Include a link to this question if it helps provide context. – nohillside Oct 01 '17 at 19:07