Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Enter info after seeing certain prompt

Expand Messages
  • daymobrew@yahoo.com
    ... [Apologies for mid-posting - I m addressing the line above] Is this suitable for a cron-job? The public keys suggestion would make this really easy - you
    Message 1 of 9 , Oct 1, 2004
    • 0 Attachment
      --- In perl-beginner@yahoogroups.com, "Jonathan Chen" <mrchen5@y...>
      wrote:
      > Thanks for expect solution. But how would it be done in perl though?
      >
      > Here is what my program will do...
      >
      > 1) ssh to the server and log in
      > 2) Execute the command and it would go back to the starting server...
      >
      > Basically its performing the command below without ssh-agent or ssh-
      > add...
      >
      > "/usr/bin/ssh root@phoenix /usr/local/logs/dcheck.sh"
      >
      >

      [Apologies for mid-posting - I'm addressing the line above]

      Is this suitable for a cron-job?
      The public keys suggestion would make this really easy - you could do
      it all in the shell script then.

      > --- In perl-beginner@yahoogroups.com, Paul Archer <tigger@i...> wrote:
      > > 10:58am, karthick.sundararajan@w... wrote:
      > >
      > > > I think expect can help you better...
      > > > try man expect
      > > >
      > > Expect is a good general solution, but if all you're trying to do is
      > login
      > > to a box using ssh, then look at ssh-agent and ssh-add. And you
      > could use
      > > those with 'expect' if you want to do more.
      > >
      > > Paul
      > >
      > >
      > >
      > > > -----Original Message-----
      > > > From: Jonathan Chen [mailto:mrchen5@y...]
      > > > Sent: Thursday, September 30, 2004 07:54
      > > > To: perl-beginner@yahoogroups.com
      > > > Subject: [PBML] Enter info after seeing certain prompt
      > > >
      > > >
      > > > Hello all,
      > > >
      > > > I am wondering how I would go about writing a perl program where
      > it
      > > > would automatically enter a data when specific prompts shows up.
      > I'm
      > > > trying to do write a perl program where it would ssh from one
      > linux
      > > > system to another and when prompted for password, perl would enter
      > > > that one in. I sure do not want the password saved in the program
      > > > itself but would be saved first once the program starts.
      > > >
      > > > Once saved, the program will later enter those passwords in when
      > > > seeing the line for entering the password.
      > > >
      > > > Thanks for any help you can give. I tried to think of a way in
      > BASH
      > > > and I can not think of a solution either since I'm a beginner in
      > both
      > > > languages.
    • Jonathan Chen
      ... though? ... server... ... ssh- ... do ... You know, I actually have trouble getting RH7 through 9 to work with passwordless login. Well not actually
      Message 2 of 9 , Oct 1, 2004
      • 0 Attachment
        --- In perl-beginner@yahoogroups.com, daymobrew@y... wrote:
        > --- In perl-beginner@yahoogroups.com, "Jonathan Chen" <mrchen5@y...>
        > wrote:
        > > Thanks for expect solution. But how would it be done in perl
        though?
        > >
        > > Here is what my program will do...
        > >
        > > 1) ssh to the server and log in
        > > 2) Execute the command and it would go back to the starting
        server...
        > >
        > > Basically its performing the command below without ssh-agent or
        ssh-
        > > add...
        > >
        > > "/usr/bin/ssh root@phoenix /usr/local/logs/dcheck.sh"
        > >
        > >
        >
        > [Apologies for mid-posting - I'm addressing the line above]
        >
        > Is this suitable for a cron-job?
        > The public keys suggestion would make this really easy - you could
        do
        > it all in the shell script then.
        >

        You know, I actually have trouble getting RH7 through 9 to work with
        passwordless login. Well not actually passwordless but still I tried
        to find solutions via web and they are seems confusing to me.

        Got a good website to help me with password solution? I am thinking
        of a temporarily solution till someone figures out how do the "Expect"
        like scripting with PERL. Perl is what I want to master. =)
      • Ken Wolcott
        ... cat /etc/redhat-release Red Hat Linux release 9 (Shrike) /msa3530 which expect expect is /usr/bin/expect Guess you didn t install all of Red Hat. Ken
        Message 3 of 9 , Oct 1, 2004
        • 0 Attachment
          On Thu, 2004-09-30 at 21:43, Jonathan Chen wrote:
          > Yes. There is a module for it. I was hoping that with someone's help
          > of writing a module similar to the one on cpan would help me do
          > similar things when writing other programs. I am kinda aware of what
          > "Expect" is and want perl to emulate it. I tried to look for "Expect"
          > in RH 7 and RH9 and there is no such program.


          cat /etc/redhat-release
          Red Hat Linux release 9 (Shrike)
          /msa3530> which expect
          expect is /usr/bin/expect

          Guess you didn't install all of Red Hat.

          Ken
        • Jeff Eggen
          ... Are you using openssh? 1. Generate private / public keypair on source host with ssh-keygen command. 2. Copy public key to target server, put in a file
          Message 4 of 9 , Oct 1, 2004
          • 0 Attachment
            >Got a good website to help me with password solution? I am thinking
            >of a temporarily solution till someone figures out how do the "Expect"
            > like scripting with PERL. Perl is what I want to master. =)

            Are you using openssh?

            1. Generate private / public keypair on source host with ssh-keygen command.
            2. Copy public key to target server, put in a file called authorized_keys in the $HOME/.ssh/ directory.
            3. On source server, run "ssh targetserver date" to test it, where targetserver is the target server.

            This should get you set up to not require a password: if it doesn't work, then your ssh server config needs tweaking. This would be odd, as most of the time the default config will allow for this behavior. Note that for this setup, you still need whatever passphrase is on the private key. If you create the key without a passphrase, then you can get in without any interaction at all.

            As for the Perl / Expect thing, you could always download the Expect module from the CPAN and look at how it does whatever it does. However, if you want to master Perl, then one of the first steps is realizing that if someone has made a module to do something difficult, use theirs. Reinventing the wheel is typically more trouble than it's worth. For learning purposes, I got more value out of the O'Reilly books (especially Randal's books, and the Cookbooks) and writing small programs using them as references than anything else.

            Hope this helps somewhat,

            Jeff Eggen
            IT Programmer Analyst
            Saskatchewan Government Insurance
            Ph (306) 751-1795
            email jeggen@...

            ************DISCLAIMER*************
            This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the named addressee, please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that using, disclosing, copying or distributing the contents of this information is strictly prohibited.
            ************DISCLAIMER*************
          Your message has been successfully submitted and would be delivered to recipients shortly.