Find the answer to your Linux question:
Page 2 of 5 FirstFirst 1 2 3 4 5 LastLast
Results 11 to 20 of 42
Originally Posted by ngmlinux For instance if I write a script like this: Code: #!/bin/sh ftp -vn ftp.mysite.com <<SCRIPT user myusername mypassword passive ! ls SCRIPT exit 0 Then the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044

    Quote Originally Posted by ngmlinux
    For instance if I write a script like this:
    Code:
    #!/bin/sh
    
    ftp -vn ftp.mysite.com <<SCRIPT
    user myusername mypassword
    passive
    !
    ls
    SCRIPT
    
    exit 0
    Then the following will occur line by line as follows:

    Code:
    !   # this will be ignored as seen by the outcome of "ls"
    ls # this should list the contents of the local directory not that of
       # the ftp, but in practice it lists the contents of the ftp, because 
       # "!" never susspended ftp to bring back the shell
    SCRIPT # this logs out of and quits the ftp client applicaton entirely
    Thus it appears the ! character is reserved for something special in
    shell scripts and thus presents a problem for what I am attempting to
    do. The ! character appears to pose an even greater issue when
    including it in a shell while loop.

    I've attempted replacing ! with '!', `!`, /! and /'!' none of which brought about any success.
    Are you saying that you've put the '!' on its own on a line (with a comment after it)? If so, that's your problem - it'll execute the program after the '!', and you haven't specified one. Use "!ls" and see the difference. It behaves differently if you do it from an interactive ftp session.

  2. #12
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,132
    Have you tried defining a macro in ftp? Use the macdef command to run through the macro through ftp.

  3. #13
    Linux Newbie
    Join Date
    May 2005
    Posts
    127
    Could you elaborate a bit on the usage of macdef? macdef isn't recognized as an ftp command so assume this a bash script command? I didn't have much luck finding a applicable example, so if you could post a few lines or a link, that should help.

    Thanks.

  4. #14
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,132
    I have it here in my ftp, it is possible that your version doesn't include it. You said it was on an embedded device. Is there a user it runs under? I found some unfortunate news for all of us while looking into this. Dos FTP supports scripting using the -s switch, unfortunately the gnu version does not.

  5. #15
    Linux Newbie
    Join Date
    May 2005
    Posts
    127
    So in short, you're saying I need a special version of ftp to use macdef? Not worth it since it can easily take a week or two to install anything on this particular embedded linux due to a library kernel mismatch bug.

  6. #16
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,132
    No sorry I was just unsure, I assumed it was a standard option. Is there any macro options in the man page for your ftp? I remember there was a config file called .net something in the users home directory for setting macros and such, which is why I asked earlier if there was a user associated. I think a dollar symbol is used to launch a macro - i.e. ftp $macroname. Does this respond at all?

  7. #17
    Linux Newbie
    Join Date
    May 2005
    Posts
    127
    The $ symbol can be used to insert the contents of a variable (I think this may be called dereferencing). So if you set foo = bar then using $foo would be equivalent to using bar (the two are interchangeable). I'm still surprised the '!' didn't work, because single quotes are supposed to make sure the literal use of ! is used and that the bash interpreter ignores it. Perhaps I could try:
    Code:
    var = '!'
    '$var'
    kind of a combo of the two, it's a long shot but something I haven't attempted yet.[/code]

  8. #18
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,132
    Oh I understand the concept of variables in Bash, ...from the man pages ...
    ! [command [args]]
    Invoke an interactive shell on the local machine. If there
    are arguments, the first is taken to be a command to execute
    directly, with the rest of the arguments as its arguments.

    $ macro-name [args]
    Execute the macro macro-name that was defined with the macdef
    command. Arguments are passed to the macro unglobbed.
    If that clears up anything for you.

  9. #19
    Linux Newbie
    Join Date
    May 2005
    Posts
    127
    I tried:
    Code:
    var = '!'
    '$var'
    Still no luck.

  10. #20
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,132
    what options do you get if you run [cpde]ftp --help[/code]?

    Just wondering what your version of ftp has.

Page 2 of 5 FirstFirst 1 2 3 4 5 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
  •