General discussion

  • Creator
    Topic
  • #2073669

    Passing arguments in Unix Shell Script

    Locked

    by pcammuso ·

    In a shell script, I want to be able to “ftp” to a machine and pass the username, password, put command, etc. but whenenver I run the script, it sits there waiting for me to enter the info. I predefined them in the script, but I don’t know how to pass them to the ftp command to get them to execute.

    Thanks

    Paul

All Comments

  • Author
    Replies
    • #3893669

      Passing arguments in Unix Shell Script

      by rkeckler2000 ·

      In reply to Passing arguments in Unix Shell Script

      Try this in your script

      ftp computer << EOF user username passwd cd /to/a/directory put files bye EOF

      • #3894726

        Passing arguments in Unix Shell Script

        by pcammuso ·

        In reply to Passing arguments in Unix Shell Script

        Sorry, this didn’t work! I ended up writing the ftp commands to a file as follows

        ftp hostname < file.txt file.txt contains all I needed Thanks for the repsonse anyway

    • #3893556

      Passing arguments in Unix Shell Script

      by ajohn ·

      In reply to Passing arguments in Unix Shell Script

      Paul,
      Basically, you need username, password, and the put command. The username and password should be written to the users .netrc file. It should look like this:
      default
      login whateverusername
      password whateverpassword
      I think permissions haveto be set to r——–. (chmod 400)
      Then, all that is left is the put command. Write out the put command to a file and cat the file piping throu the ftp command.
      like this:
      echo “put filename” > dummyfile
      cat dummyfile | ftp
      I think this shouldat least get you started.
      John

Viewing 1 reply thread