Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
I am using a bash script to ftp a file from a suse linux server to a windows box. Originally it was just an IP addr we went to, but ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141

    Help w/ftp script


    I am using a bash script to ftp a file from a suse linux server to a windows box. Originally it was just an IP addr we went to, but it has now changed to a share on a virtual windows server.
    What I am having a specific problem with is the \\ in the user portion of the script, I have tried everything I know to get the script to accept this but to no avail.
    Any help is greatly appreciated.
    Thanks
    Mace

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    a windows share and a ftp share are totally not the same thing.

    what does your script look like? are you using samba commands? if so, you need to use twice as many '\' than normal.

    e.g.
    a normal windows share: \\blah\sharename

    in linux over samba:
    \\\\blah\\sharename
    linux user # 503963

  3. #3
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    Thank you, the \\\\ worked great, but now I am stuck getting the password to work.
    I have tried the original space between the username and password and then I tried inserting \ (up to 4)
    With the space the username and password were butted together(ie usernamepassword)
    With \ (up to 4 and and or a space ) it wold give username\password BUT cut the password off by the last 3 characters.
    So close but so far
    Thanks
    Mace

  4. #4
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    Code:
    smbclient \\\\blah\\sharename yourpassword -u username
    If that doesn't work, if you can post your script that would be most helpful.

    OR, you can use an authentication file. The command would look like:
    Code:
    smbclient \\\\\blah\sharename -A /path/to/config/file
    config file would contain something like:
    Code:
    username = foo
    password = bar
    also keeps the usernames and passwords out of your scripts, you know, security-type stuff
    Last edited by scathefire; 12-13-2011 at 06:29 PM. Reason: added an alternative
    linux user # 503963

  5. #5
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    Here is the ftp portion of the script..


    ftp -n -v -i IPADDRESS port # << EOF
    user share\\\username password

    Thanks
    Mace

  6. #6
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    FYI

    this all works if we do it manually

    mace

  7. #7
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    Your script makes no sense. Are you using SAMBA or FTP? You are trying to merge to totally different protocols together. Whichever protocol you use will yield a different result.

    According to your script you are using FTP, so that means you have installed a FTP server, probably through IIS. Note, these are all assumptions.

    So if you are using FTP, your script would not even need the '\\' characters you are talking about.

    Code:
    IPADDRESS=some.ip.address
    USER=someuser
    PW=somepass
    ftp -n $IPADDRESS <<UPLOAD
            user $USER $PW
            ascii
            #put other commands here
            quit
    UPLOAD
    If you are trying to use Windows File sharing (SMB/Server Message Block/SAMBA), that is a totally different script.
    linux user # 503963

  8. #8
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    using ftp..I didn't send the whole script just the ftp portion(where the problem lives).
    Also the way the current script is written I do need the \s before I didn't
    as i said this worked for years until they changed the receiving end
    I'll try the symbolics
    thx
    mace

  9. #9
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    ok i have misinformed you a bit...yes it is a windows share but we now have to put in the domain not a windows share name.
    here is the error i get:
    220 Microsoft FTP Service
    331 Password required for domain\userid.
    530 User domain\userid cannot log in.
    Login failed.
    mace

  10. #10
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    Ok, so you are logging in with domain credentials then. I see now why you were wanting the '\'. The reason why you use 2 of them is because they hold special meaning in the shell (as escape characters).

    Does this change anything:
    Code:
    IPADDRESS=some.ip.address
    USER=mydomain\\myuser
    PW=somepass
    ftp -n $IPADDRESS <<UPLOAD
            user $USER
            $PW
            ascii
            #put other commands here
            quit
    UPLOAD
    I don't work with Microsoft FTP service too much, its just a matter of finding what syntax its looking for really. Most FTP services follow relatively similar patterns.

    The password wouldn't happen to contain characters like '\' or '@' or '#'?
    linux user # 503963

Page 1 of 2 1 2 LastLast

Posting Permissions

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