Results 1 to 6 of 6

Thread: SHELL File Not Executing FTP command

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    3

    Default 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>'
    
    ftp -n $HOST <<EOT
    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

  2. #2
    Administrator AndrewT's Avatar
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    3,639

    Default

    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?

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    3

    Default

    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

  4. #4
    Administrator AndrewT's Avatar
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    3,639

    Default

    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.

  5. #5
    Junior Member
    Join Date
    Jan 2013
    Posts
    3

    Default

    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

  6. #6
    Administrator AndrewT's Avatar
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    3,639

    Default

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •