Objective: When we are executing our Perl script by using Autosys tool (Job Scheduling tool). It is not able to recognise Expect.pm which I used in my Perl code. And I am getting the below error. Can't call method "expect" on an undefined value at /xxxx/bin/run_EMCTSftpPutEclerxFile.pl line 18. Expect is not working go But when I am executing it manually It works flawlesly. Pl. find my Perl script below: 1 #!/opt/perl/5.8.0/bin/perl 2 #ident "%W%" 3 4 use Expect; 5 6 $xxxx_FTP_HOST="xxxxx"; 7 $xxxx_FTP_USER="xxxx"; 8 $xxxx_FTP_PASS="xxxxx"; 9 $xxxxx_FTP_LDIR="/opt/ftp/pub/outgoing"; 10 $xxxxx_FTP_LFILE=$ARGV[0]; 11 $timeout = 10; 12 $command = 'sftp'; 13 14 $params = ("$xxxxxR\@$xxxxX_FTP_HOST"); 15 16 $exp=Expect->spawn($command, $params) or print "Expect is not working go \n"; 17 18 $exp->expect($timeout, "Password:"); 19 20 $exp->send("$Exxxxx_FTP_PASS\n"); 21 22 $exp->expect($timeout, "sftp>"); 23 24 $exp->send("binary\r"); 25 26 $exp->expect($timeout, "sftp>"); 27 28 $exp->send("put $xxxxxX_FTP_LDIR/$xxxxx_FTP_LFILE \n"); 29 30 $exp->expect($timeout, "sftp>"); 31 32 $exp->send("bye\n"); 33 34 $exp->soft_close();

In reply to Getting Error in Expect when using it with Perl by unixmonster
in thread In a multithreading Perl Code How to Exit one thread while outher thread keeps running ? by unixmonster

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.