SHELL File Not Executing FTP command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Telford Internet
    Junior Member
    • Jan 2013
    • 3

    SHELL File Not Executing FTP command

    I have the following script and it does everything EXCEPT the actual FTP transfer. I get advised that "/home/<account>/backup/backup_ftp.sh: line 30: ftp: command not found". I have highlighted row 30.

    Any help would be appreciated.

    Code:
    #!/bin/sh
    
    
    #	Create the names for our sql file and compressed backup files.
    fileSQL="xxxx_db_backup.`date +%w`.sql"
    fileSQLZIP="xxxx_db_backup.`date +%w`.tgz"
    fileHomeZip="xxxx_home.`date +%w`.tgz"
    
    
    #	Database Details
    userDB="yyyy_rrrr"
    passDB="xxxxxxxx"
    nameDB="yyyy_rrrr"
    
    #	Home Directory Files
    tar cfz $fileHomeZip /home/<account>/public_html/
    
    
    #	Create the Dump/Copy of the database
    /usr/bin/mysqldump -u $userDB -p$passDB -c --add-drop-table $nameDB > /home/<account>/$fileSQL
    
    #	Compress the sql File Ready for FTP
    tar cfz $fileSQLZIP /home/<account>/$fileSQL
    
    #	FTP the file to another host location
    HOST='xxx.xxx.xxx.xxx'
    USER='<user>'
    PASSWD='<pass>'
    
    [B][COLOR="#B22222"][SIZE=3]ftp -n $HOST <<EOT[/SIZE][/COLOR][/B]
    USER $USER $PASSWD
    put $fileSQLZIP
    put $fileHomeZip
    quit
    EOT
    
    #	Delete the Database Copy from the the Account
    cd /home/<account>/
    #rm $fileSQL
    #rm $fileSQLZIP
    #rm $fileHomeZip
  • AndrewT
    Administrator
    • Mar 2004
    • 3653

    #2
    It looks like the FTP binary may not be available in your server's CageFS skeleton. We can probably get this added for you but have you considered a much more secure means of transferring such data, such as SCP?

    Comment

    • Telford Internet
      Junior Member
      • Jan 2013
      • 3

      #3
      Hi

      No I hadn't considered it. Will look it up and see what I can find.
      Was just using something that had worked for me a while back.

      Thanks

      Comment

      • AndrewT
        Administrator
        • Mar 2004
        • 3653

        #4
        Gotcha, I would highly recommend using SCP instead. If you do require the FTP binary though just submit a ticket noting this exact same issue and we can hopefully get it sorted out for you.

        Comment

        • Telford Internet
          Junior Member
          • Jan 2013
          • 3

          #5
          Hi ... again

          I have located some SCP scripts but I am getting the following error.

          /usr/local/cpanel/bin/jailshell: /home/<account>/backup/backup_ftp_scp.sh: /usr/bin/expect: bad interpreter: No such file or directory

          My code is below but if you have an example, please let me know.

          Code:
          #!/usr/bin/expect
          
          
          #	Create the names for our sql file and compressed backup files.
          fileSQL="aaaaa_db_backup.`date +%w`.sql"
          fileSQLZIP="aaaaa_db_backup.`date +%w`.tgz"
          fileHomeZip="aaaaa_home.`date +%w`.tgz"
          
          
          #	Database Details
          userDB="aaaaa_wp939"
          passDB="password"
          nameDB="aaaaa_wp939"
          
          #	Home Directory Files
          tar cfz $fileHomeZip /home/<account>/public_html/
          
          
          #	Create the Dump/Copy of the database
          /usr/bin/mysqldump -u $userDB -p$passDB -c --add-drop-table $nameDB > /home/<account>/$fileSQL
          
          #	Compress the sql File Ready for FTP
          tar cfz $fileSQLZIP /home/<account>/$fileSQL
          
          #	FTP the file to another host location
          HOST='xx.xx.xx.xx'
          USER='user'
          PASSWD='password'
          
          # connect via scp
          scp "/home/<account>/$fileHomeZip" "ftpUser:/home/<remoteAccount>/public_html/"
          #######################
          expect {
            -re ".*es.*o.*" {
              exp_send "yes\r"
              exp_continue
            }
            -re ".*sword.*" {
              exp_send "password\r"
            }
          }
          interact
          
          
          #	Delete the Database Copy from the the Account
          cd /home/<account>/
          #rm $fileSQL
          #rm $fileSQLZIP
          #rm $fileHomeZip

          Comment

          • AndrewT
            Administrator
            • Mar 2004
            • 3653

            #6
            That script is using expect (instead of sh like your initial one) which likewise isn't available in the default CageFS. That said, the script is meant to be run interactively since it will prompt you for the password which doesn't really work with any kind of automation. You're better off using SSH keys to connect in that case since it wouldn't require any entering of a password.

            That said, if you're not familiar with shell scripting, setting up SSH keys, etc. the best option is ultimately going to be cPanel's own backup option that you can execute via cPanel and can even specify to have it transferred offsite via FTP, SCP, etc.

            Comment

            Working...