Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a list of files changes, example:

/opt/lampp/htdocs/project/index.php
/opt/lampp/htdocs/project/css/styles.css
/opt/lampp/htdocs/project/css/styles001.css
/opt/lampp/htdocs/project/system/model/core.php
/opt/lampp/htdocs/project/system/controllers/admin/users.php

How can I do to upload them in one shot via FTP using Linux?

share|improve this question

1 Answer 1

You can find an example of how to do this here.

From the page itself:

## upload the files
INPUT=/path/to/list_of_files_to_upload
LOCALBASE=/home/pete/website        #local directory that corresponds to the root of the website

for ITEM in $(cat $INPUT); do
      FILE=$(basename $ITEM)
      LOCALDIR=$(dirname $ITEM)

      if  [ "$LOCALDIR" == "$LOCALBASE" ]; then
                REMOTEDIR="/"
      else
              REMOTEDIR=${LOCALDIR#$LOCALBASE}
      fi

  ## ftp starts here
  ftp -v -n $SERVER <<END_OF_SESSION
  user $USER $PASSW
  $FILETYPE
  lcd $LOCALDIR
  cd $REMOTEDIR
  put $FILE
  bye
  END_OF_SESSION
done
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.