Find the answer to your Linux question:
Page 3 of 5 FirstFirst 1 2 3 4 5 LastLast
Results 21 to 30 of 42
Code: ! debug mdir sendport site $ dir mget put size account disconnect mkdir pwd status append exit mls quit struct ascii form mode quote system bell get modtime recv ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #21
    Linux Newbie
    Join Date
    May 2005
    Posts
    127

    Code:
    !               debug           mdir            sendport        site
    $               dir             mget            put             size
    account         disconnect      mkdir           pwd             status
    append          exit            mls             quit            struct
    ascii           form            mode            quote           system
    bell            get             modtime         recv            sunique
    binary          glob            mput            reget           tenex
    bye             hash            newer           rstatus         tick
    case            help            nmap            rhelp           trace
    cd              idle            nlist           rename          type
    cdup            image           ntrans          reset           user
    chmod           lcd             open            restart         umask
    close           ls              prompt          rmdir           verbose
    cr              macdef          passive         runique         ?
    delete          mdelete         proxy           send
    Again if at all possible I really would like to acomplish this without using non standard ftp applications that need to be installed or other scripting languages that need to be installed.

  2. #22
    Linux Newbie
    Join Date
    May 2005
    Posts
    127

    Partial success

    Using a ! alone in a bash script has given me no success, however I was able to partially get some things working. If I issue shell commands on the same line as the ! they will execute in the shell, the script automatically returns to ftp on the next line unless a new ! is issued. The following script code successfully echos the text in the shell:
    Code:
    !echo "Made it to the shell!"
    !echo "Made it to the shell2!"
    and
    Code:
    !echo "Made it to the shell1!";echo "Made it to the shell2!"
    also outputs the same.

    However running echo commands seems to be all I can do, I need to be able to run a for loop than can loop both shell and ftp operations. I know how to write the loops they just don't seem to work with the !'s.

    Another big issue i'm facing is that when I do something like:
    Code:
    1 ftp -vn ftp.myserver.com <<SCRIPT
    2 user myusername mypassword
    3 binary
    4 put foo
    5 SCRIPT
    The term "SCRIPT" on line 5 will kill / disconnect my ftp client. I am still a bit unclear as to what the "<<SCRIPT" and "SCRIPT" commands are needed for. I know my program doesn't work without them surrounding the ftp portions of my code, however I'm not quite clear as to why?

    Is there anyway I can command multiple shells from one shell script? That may be a good work around to these issues.

  3. #23
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,133
    glad to hear you have some success with that. I noticed you hcave the macdef command is present in your help. When inside the ftp session, what happens when you type macdef?

  4. #24
    Linux Newbie
    Join Date
    May 2005
    Posts
    127
    Here's an example macro I've created:

    Code:
    ftp> macdef
    &#40;macro name&#41; test
    Enter macro line by line, terminating it with a null line
    ls
    !
    ls
    
    ftp>
    Do you think the ! would for some reason work in a macro? Or were you thinking of something else?

  5. #25
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Quote Originally Posted by ngmlinux
    I am still a bit unclear as to what the "<<SCRIPT" and "SCRIPT" commands are needed for. I know my program doesn't work without them surrounding the ftp portions of my code, however I'm not quite clear as to why?
    If in a shell script you have a line with command<<string then
    the following lines will be fed to the standard input of command
    until a line with just string appears.
    I need to be able to run a for loop than can loop both shell and ftp operations.
    Can you give us the loop you're trying to create ?

  6. #26
    Linux Newbie
    Join Date
    May 2005
    Posts
    127
    I have a program that generates a file every time it is run, let's call this generatedata. I want to take the file that was generated and ftp it then generate another file then ftp it then generate another file then ftp it and so on X number of times. I want to run generate data as soon as the previous ftp transter completes, therefore I CAN NOT LOG OUT AND LOG BACK into the ftp each time because that wastes a substantial amount of time.

    Here is the pseudo code of what I want to do:

    connect to ftp and login and set passive mode
    loop_this:
    ./generatedata -o data.out #in shell
    put data.out #in ftp
    end loop_this

  7. #27
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Try the following:
    Code:
    mkfifo name
    ftp < name &
    loop_this&#58;
    ./generatedata -o data.out
    echo 'put data.out' >> name
    end loop_this
    The line with ftp may need adding some parameters but hopefully
    you get the idea.Every time you want ftp to execute some command
    you do
    Code:
    echo 'command' >> name

  8. #28
    Linux Newbie
    Join Date
    May 2005
    Posts
    127
    Sorry, but I'm not quite sure where in that script authentication is done. Should something like the following work?:

    Code:
    #!/bin/sh
    mkfifo myname
    ftp -vn ftp.mysite.com < myname &
    echo 'user myusername mypassword' >> myname
    echo 'passive' >> myname
    echo 'cd /stuff/test_data/' >> myname
    for i in &#91;seq 1 5&#93;
      do
         ./generatedata -o data.out
         echo 'put data.out' >> myname
      done
    echo 'logout' >> myname
    exit 0

  9. #29
    Linux Newbie
    Join Date
    May 2005
    Posts
    127
    The script runs so long as I hae mkfifo installed, however the syntax does not execute as expected. Even though my loop specifies that generatedata be run then ftp then generate data then ftp... It does all the shell commands 3 times and then does the ftp commands. I think the reason being that the script does not wait for the ftp commands to finish executing. This can be demonstrated by the shell output bellow:

    Code:
    &#91;root@localhost my_code&#93;# ./mkfifo_script.sh
    mkfifo&#58; cannot create fifo `my_ftp'&#58; File exists
    cd /stuff/test_data/
    generatedata... success
    generatedata... success
    generatedata... success
    &#91;root@localhost my_code&#93;# Connected to ftp.mysite.com.
    220---------- Welcome to Pure-FTPd ----------
    220-You are user number 14 of 100 allowed.
    220-Local time is now 18&#58;58. Server port&#58; 21.
    220-This is a private system - No anonymous login
    220-IPv6 connections are also welcome on this server.
    220 You will be disconnected after 15 minutes of inactivity.
    500 This security scheme is not implemented
    500 This security scheme is not implemented
    KERBEROS_V4 rejected as an authentication type
    Remote system type is UNIX.
    Using binary mode to transfer files.
    331 User myusername OK. Password required
    230-User myusername has group access to&#58;  users
    230-This server supports FXP transfers
    230 OK. Current restricted directory is /
    Passive mode on.
    200 TYPE is now 8-bit binary
    local&#58; data.out remote&#58; data.out
    227 Entering Passive Mode &#40;100,124,40,125,136,161&#41;
    150 Accepted data connection
    226-95932.0 Mbytes free disk space
    226-File successfully transferred
    226 1.961 seconds &#40;measured here&#41;, 3.79 Kbytes per second
    7616 bytes sent in 9.2e-05 seconds &#40;8.1e+04 Kbytes/s&#41;
    local&#58; data.out remote&#58; data.out
    227 Entering Passive Mode &#40;100,124,40,125,136,162&#41;
    150 Accepted data connection
    226-95931.9 Mbytes free disk space
    226-File successfully transferred
    226 2.125 seconds &#40;measured here&#41;, 3.50 Kbytes per second
    7616 bytes sent in 6.1e-05 seconds &#40;1.2e+05 Kbytes/s&#41;
    local&#58; data.out remote&#58; data.out
    227 Entering Passive Mode &#40;100,124,40,125,136,163&#41;
    150 Accepted data connection
    226-95931.8 Mbytes free disk space
    226-File successfully transferred
    226 2.158 seconds &#40;measured here&#41;, 3.45 Kbytes per second
    7616 bytes sent in 6.9e-05 seconds &#40;1.1e+05 Kbytes/s&#41;
    ?Invalid command
    221-Goodbye. You uploaded 23 and downloaded 0 kbytes.
    221 Logout.
    Getting close. Any ideas, to make the shell commands wait for the ftp commands to finish? Simply adding noops won't work since ftp commands can vary in the time they take to execute, so I need to do something where the script waits for those commands to finish.

  10. #30
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    You can put
    Code:
    ftp -vn ftp.mysite.com < myname >> output &
    and have the shell read output again and again.When ftp reports
    that it has finished with the previous job then the shell can proceed.

Page 3 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
  •