<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: expect help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075253#M717221</link>
    <description>What are you trying to accomplish with this? I assume you want the output of the ls command to be displayed to the screen. The idea of the timeout is to be able to report an error if you do not get the expected results in some period of time. Your expect statement is only looking for a timeout, you have no response you are looking for such as the shell prompt.&lt;BR /&gt;&lt;BR /&gt;I am new to expect as well, but I do have a couple of working scripts so I might be able to help once I understand what you really want to do.&lt;BR /&gt;&lt;BR /&gt;-Dave</description>
    <pubDate>Fri, 19 Sep 2003 14:28:57 GMT</pubDate>
    <dc:creator>Dave Johnson_1</dc:creator>
    <dc:date>2003-09-19T14:28:57Z</dc:date>
    <item>
      <title>expect help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075252#M717220</link>
      <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;I have an expect program in which I am trying to timeout after sometime, but my program is coming out before the timeout happens.&lt;BR /&gt;&lt;BR /&gt;Here is the program :-&lt;BR /&gt;*********************&lt;BR /&gt;&lt;BR /&gt;#! /usr/local/bin/expect&lt;BR /&gt;&lt;BR /&gt;proc spawn_proc {args} {&lt;BR /&gt;    global temp_id&lt;BR /&gt;    puts "\t$args"&lt;BR /&gt;    eval spawn $args&lt;BR /&gt;    expect  {&lt;BR /&gt;      timeout { send_user "\nTimed out\n" }&lt;BR /&gt;    }&lt;BR /&gt;    return $spawn_id&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# The program should wait for 100 secs and #then timeout&lt;BR /&gt;set timeout 100&lt;BR /&gt;spawn_proc ls&lt;BR /&gt;&lt;BR /&gt;puts "program completed successfully "&lt;BR /&gt;# program end&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;****************************************&lt;BR /&gt;But with a small modification in the above programs it works as expected.&lt;BR /&gt;&lt;BR /&gt;Modified program :-&lt;BR /&gt;*********************&lt;BR /&gt;&lt;BR /&gt;#! /usr/local/bin/expect&lt;BR /&gt;&lt;BR /&gt;proc spawn_proc {args} {&lt;BR /&gt;    global temp_id&lt;BR /&gt;    puts "\t$args"&lt;BR /&gt;    eval spawn $args&lt;BR /&gt;    return $spawn_id&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# The program should wait for 100 secs and #then timeout&lt;BR /&gt;&lt;BR /&gt;set timeout 100&lt;BR /&gt;spawn_proc ls&lt;BR /&gt;&lt;BR /&gt;# expect statement is taken off in the #spawn_proc and kept here .&lt;BR /&gt;expect  {&lt;BR /&gt;      timeout { send_user "\nTimed out\n" }&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;puts "program completed successfully "&lt;BR /&gt;&lt;BR /&gt;# program end&lt;BR /&gt;&lt;BR /&gt;***********************************************&lt;BR /&gt;&lt;BR /&gt;One more difference in the outputs of the above two programs is In the 1st case ( non-timedout case) it displays the output of "ls"&lt;BR /&gt;command on the screen and exits without&lt;BR /&gt;waiting for the timeout to happen . But in second case it doesn't display the output to the screen , but it waits till timeout occurs .&lt;BR /&gt;&lt;BR /&gt;Can somebody explain me the reasons for these behaviours ???&lt;BR /&gt;&lt;BR /&gt;TIA,&lt;BR /&gt;vara.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Sep 2003 13:43:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075252#M717220</guid>
      <dc:creator>varap</dc:creator>
      <dc:date>2003-09-19T13:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: expect help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075253#M717221</link>
      <description>What are you trying to accomplish with this? I assume you want the output of the ls command to be displayed to the screen. The idea of the timeout is to be able to report an error if you do not get the expected results in some period of time. Your expect statement is only looking for a timeout, you have no response you are looking for such as the shell prompt.&lt;BR /&gt;&lt;BR /&gt;I am new to expect as well, but I do have a couple of working scripts so I might be able to help once I understand what you really want to do.&lt;BR /&gt;&lt;BR /&gt;-Dave</description>
      <pubDate>Fri, 19 Sep 2003 14:28:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075253#M717221</guid>
      <dc:creator>Dave Johnson_1</dc:creator>
      <dc:date>2003-09-19T14:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: expect help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075254#M717222</link>
      <description>What are you trying to accomplish with this? I assume you want the output of the ls command to be displayed to the screen. The idea of the timeout is to be able to report an error if you do not get the expected results in some period of time. Your expect statement is only looking for a timeout, you have no response you are looking for such as the shell prompt.&lt;BR /&gt;&lt;BR /&gt;I am new to expect as well, but I do have a couple of working scripts so I might be able to help once I understand what you really want to do.&lt;BR /&gt;&lt;BR /&gt;-Dave</description>
      <pubDate>Fri, 19 Sep 2003 14:29:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075254#M717222</guid>
      <dc:creator>Dave Johnson_1</dc:creator>
      <dc:date>2003-09-19T14:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: expect help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075255#M717223</link>
      <description>Hi Dave,&lt;BR /&gt;&lt;BR /&gt;I want my program to wait for 100 secs after "ls" is executed . Why is this not&lt;BR /&gt;happening in the 1st case ??? As I have not&lt;BR /&gt;put any matching patterns in expect , I expected the program to wait for 100 secs &lt;BR /&gt;in spawn_proc function . I could able to achieve the expected behaviour in the second&lt;BR /&gt;case with similar login . &lt;BR /&gt;&lt;BR /&gt;Just execute the above two scripts . You will&lt;BR /&gt;see the difference .&lt;BR /&gt;&lt;BR /&gt;TIA,&lt;BR /&gt;vara.</description>
      <pubDate>Sun, 21 Sep 2003 00:05:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075255#M717223</guid>
      <dc:creator>varap</dc:creator>
      <dc:date>2003-09-21T00:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: expect help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075256#M717224</link>
      <description>If you want to pause/sleep after executing a command use the sleep statement. In the first example you are look for results with in a given amount of time. Time out is a trigger that fires if no output, or specified output is not found in the timeout period. This is an error tracking not time waisting thing. To waist time after executing a command use the sleep statement.&lt;BR /&gt;&lt;BR /&gt;ex: assume root is running this&lt;BR /&gt;eval spawn $args&lt;BR /&gt;expect {&lt;BR /&gt;  timeout { send_user "\nTimed out\n" }&lt;BR /&gt;  "# "&lt;BR /&gt;}&lt;BR /&gt;sleep 100&lt;BR /&gt;&lt;BR /&gt;This will expect to get the prompt back within timeout period then sleep for 100 seconds.&lt;BR /&gt;&lt;BR /&gt;Does this help? or do I not understand your question?&lt;BR /&gt;&lt;BR /&gt;-Dave</description>
      <pubDate>Mon, 22 Sep 2003 11:09:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075256#M717224</guid>
      <dc:creator>Dave Johnson_1</dc:creator>
      <dc:date>2003-09-22T11:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: expect help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075257#M717225</link>
      <description>Hi Dave ,&lt;BR /&gt;&lt;BR /&gt;I think I didn't specify my requirement clearly . Here I am putting my requirement&lt;BR /&gt;exactly .&lt;BR /&gt;&lt;BR /&gt;For simplying the problem I have used "ls"&lt;BR /&gt;as an arg to spawn_proc. You have suggested sleep to make it wait for 100secs after the execution of "ls" . But In my actual test script I want to create and delete the files&lt;BR /&gt;under some dir ( Its a "while true" loop ).&lt;BR /&gt;&lt;BR /&gt;Here I am pasting that portion of code.&lt;BR /&gt;set timeout 300&lt;BR /&gt;spawn_proc /opt/ids/test/agent/common/realroot -c "\&lt;BR /&gt;        mkdir -p /tmp/mydirtowatch;&lt;BR /&gt;        while true&lt;BR /&gt;        do&lt;BR /&gt;           touch /tmp/mydirtowatch/file1;&lt;BR /&gt;           touch /tmp/mydirtowatch/file2;&lt;BR /&gt;           touch /tmp/mydirtowatch/file3;&lt;BR /&gt;        rm   /tmp/mydirtowatch/file?;        &lt;BR /&gt;        done"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So , Its is not just waiting . The script should execute the above while loop for 100secs and timeout after that.  So I can't&lt;BR /&gt;use sleep here.&lt;BR /&gt;&lt;BR /&gt;Let me know If you have any other idea to do this through expect script.&lt;BR /&gt;&lt;BR /&gt;Regds,&lt;BR /&gt;Vara&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Sep 2003 10:54:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075257#M717225</guid>
      <dc:creator>varap</dc:creator>
      <dc:date>2003-09-24T10:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: expect help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075258#M717226</link>
      <description>This can be done in the POSIX shell with out expect as:&lt;BR /&gt;&lt;BR /&gt;mkdir -p /tmp/mydirtowatch;&lt;BR /&gt;SECONDS=0&lt;BR /&gt;while [ $SECONDS -lt 300 ]&lt;BR /&gt;do&lt;BR /&gt;touch /tmp/mydirtowatch/file1;&lt;BR /&gt;touch /tmp/mydirtowatch/file2;&lt;BR /&gt;touch /tmp/mydirtowatch/file3;&lt;BR /&gt;rm /tmp/mydirtowatch/file?; &lt;BR /&gt;done</description>
      <pubDate>Wed, 24 Sep 2003 11:14:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075258#M717226</guid>
      <dc:creator>Dave Johnson_1</dc:creator>
      <dc:date>2003-09-24T11:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: expect help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075259#M717227</link>
      <description>try using &lt;BR /&gt;"set timeout -a"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Sep 2003 10:27:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expect-help/m-p/3075259#M717227</guid>
      <dc:creator>Paddy_1</dc:creator>
      <dc:date>2003-09-29T10:27:55Z</dc:date>
    </item>
  </channel>
</rss>

