Find the answer to your Linux question:
Results 1 to 4 of 4
Hi I am writing a bash ftp script. Is there a way to use the ftp put command with a regular expression to send only selected files (only those that ...
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    15

    ftp put regular expression

    Hi

    I am writing a bash ftp script.
    Is there a way to use the ftp put command with a regular expression to send only selected files (only those that do not begin by "boutique_"?

    Thanks

    Code:
    #!/bin/bash
    /usr/bin/ftp -inv serveraddress<<ENDFTP
    user user pass
    cd /htdocs
    bin
    lcd /site
    put !(boutique_*).php 
    bye
    ENDFTP

  2. #2
    Just Joined!
    Join Date
    Nov 2010
    Posts
    15
    up! please

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    You need to check the mput command. According to the ftp man page, mput does globbing the same as csh. I don't know how csh does its globbing, so that may be a good place to start.
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    Just Joined!
    Join Date
    Nov 2010
    Posts
    15
    Thanks I use mput now.
    But I still have a problem with the special query on the file names

    Code:
    #!/bin/bash
    
    #shopt -s extglob
    
    jojo=`find . -maxdepth 1 -type f -not \( -name "boutique_*.php" \) -name "*.php"`;
    
    /usr/bin/ftp -inv server<<ENDFTP
    user login pass
    cd /htdocs
    bin
    lcd /localdir
    mput "$jojo"
    bye
    ENDFTP
    ftp says "invalid command"

    Can someone help me get this done?

Posting Permissions

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