I have the following script which works fine on all of my servers except for one.The problem is that for this particular server, it is not waiting for the previous command to finish before it sends the next command. I have assured myself that the prompt variable is unique, any help would be appreciated.
sub run_command { my ($in_prompt,$in_command)=@_; print $rlogin "$in_command\r"; $rlogin->expect(300,'-re',$in_prompt); }#end run_command sub rlogin { my ($in_hostname,$in_password,$in_prompt,$in_type)=@_; $rlogin=Expect->spawn($in_type." ".$in_hostname); $rlogin->expect(300,"ssword:") || die "Never got password prom +pt on $host, ".$rlogin->exp_error()."\n"; print $rlogin "$in_password\r"; $match=$rlogin->expect(300,"closed by foreign host","-re",$in_ +prompt); #Used for debugging I think #die "Dumped by server\n" if $match == 1; #die "Never got shell prompt on $host, ".$rlogin->exp_error(). +"\n" unless $match; }#end rlogin rlogin($hostname,$password,$prompt,"ssh"); run_command($prompt,"export ORACLE_SID=$oracle_sid"); run_command($prompt,"cd dev"); run_command($prompt,"chmod +x *"); run_command($prompt,"exp $schema/$schema file=$file log=$log rows=no") +; run_command($prompt,"imp $schema/$schema file=$file indexfile=$indexfi +le full=y"); run_command($prompt,"./initial.pl ".$schema."_tabind LOC_".$touser." +$touser $schema ");

Edit 2001-26-06 Masem - Added code tags


In reply to perl expect prompt by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.