<?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: wait output in a script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/wait-output-in-a-script/m-p/4193493#M91380</link>
    <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;Your technique is fine.  A nice polish to your own suggestion is to have your script spawn your CheckSsh() function as a background process.&lt;BR /&gt;&lt;BR /&gt;Then, capture the PID of that process:&lt;BR /&gt;&lt;BR /&gt;# PID=$!&lt;BR /&gt;&lt;BR /&gt;Now, let the main part of your script do other work if/as necessary.  If at any time you want to cancel the CheckSSh() wait, simply issue do:&lt;BR /&gt;&lt;BR /&gt;# kill ${PID} in the script that called the function in the first place.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 07 May 2008 16:11:45 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2008-05-07T16:11:45Z</dc:date>
    <item>
      <title>wait output in a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/wait-output-in-a-script/m-p/4193492#M91379</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I am developing a script that does various functions and one of these is to check a user ssh connection from an AUTH server to the server where the script is running.&lt;BR /&gt;&lt;BR /&gt;I want to make sure the user doesnt skip this step so I have written a bit of code:&lt;BR /&gt;&lt;BR /&gt;read ANS?"Please copy and paste the authorised key for the CA user on $AUTHSERV here &amp;gt;&amp;gt;&amp;gt;"&lt;BR /&gt;&lt;BR /&gt;if [[ $ANS = $KEY ]] ; then&lt;BR /&gt;&lt;BR /&gt;    print "ssh-rsa $ANS ca@AUTHSERV" &amp;gt; $CAHOME/.ssh/authorized_keys&lt;BR /&gt;    chmod 644 $CAHOME/.ssh/authorized_keys&lt;BR /&gt;    print "INFO: Key has been accepted, please test ssh connection from $AUTHSERV and ca account and run the command 'touch /&lt;BR /&gt;tmp/ldap_ssh_test' - - you have 5 minutes "&lt;BR /&gt;    CheckSsh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;else&lt;BR /&gt;&lt;BR /&gt;    print "The key you have entered does not match the key in $CONF/ldap.CFG, check ca user key on $AUTHSERV "&lt;BR /&gt;    exit 204&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;so when the key has been inputted correctly I want my script to run the CheckSsh funciton and wait for the user to run the touch command:&lt;BR /&gt;&lt;BR /&gt;CheckSsh {&lt;BR /&gt;&lt;BR /&gt;while [[ count -lt 60 ]]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;    if [[ -f /tmp/ldap_ssh_test ]] ; then&lt;BR /&gt;     break&lt;BR /&gt;&lt;BR /&gt;    else&lt;BR /&gt;&lt;BR /&gt;    print ".\c"&lt;BR /&gt;    sleep 5 &lt;BR /&gt;&lt;BR /&gt;    fi&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;so the print ".\c" will print ...... every five seconds to show this is waiting.&lt;BR /&gt;&lt;BR /&gt;I could also put in a sum to work out how much time the user has left.&lt;BR /&gt;&lt;BR /&gt;my question is does anyone have any better syntax or ideas to display that the script is waiting? &lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;&lt;BR /&gt;chris.</description>
      <pubDate>Wed, 07 May 2008 15:24:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/wait-output-in-a-script/m-p/4193492#M91379</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2008-05-07T15:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: wait output in a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/wait-output-in-a-script/m-p/4193493#M91380</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;Your technique is fine.  A nice polish to your own suggestion is to have your script spawn your CheckSsh() function as a background process.&lt;BR /&gt;&lt;BR /&gt;Then, capture the PID of that process:&lt;BR /&gt;&lt;BR /&gt;# PID=$!&lt;BR /&gt;&lt;BR /&gt;Now, let the main part of your script do other work if/as necessary.  If at any time you want to cancel the CheckSSh() wait, simply issue do:&lt;BR /&gt;&lt;BR /&gt;# kill ${PID} in the script that called the function in the first place.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 07 May 2008 16:11:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/wait-output-in-a-script/m-p/4193493#M91380</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-05-07T16:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: wait output in a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/wait-output-in-a-script/m-p/4193494#M91381</link>
      <description>&lt;!--!*#--&gt;Hi (again) Chris:&lt;BR /&gt;&lt;BR /&gt;Here's a prototype demonstration.&lt;BR /&gt;&lt;BR /&gt;# cat ./mywaiter&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset PID&lt;BR /&gt;function spout&lt;BR /&gt;{&lt;BR /&gt;    while true&lt;BR /&gt;    do&lt;BR /&gt;        echo ".\c"&lt;BR /&gt;        kill -s 0 ${PID} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;        [ $? != 0 ] &amp;amp;&amp;amp; return 0 || sleep 1&lt;BR /&gt;    done&lt;BR /&gt;}&lt;BR /&gt;function grind&lt;BR /&gt;{&lt;BR /&gt;    typeset -i N=0&lt;BR /&gt;    while (( N &amp;lt; 30 ))&lt;BR /&gt;    do&lt;BR /&gt;        (( N=${N}+1 ))&lt;BR /&gt;        echo "pass_${N}" &amp;gt;&amp;gt; /tmp/sh.$$&lt;BR /&gt;        sleep 1&lt;BR /&gt;    done&lt;BR /&gt;}&lt;BR /&gt;grind &amp;amp;&lt;BR /&gt;PID=$!&lt;BR /&gt;echo "pid=$$/${PID} executing -- please wait\c"&lt;BR /&gt;spout&lt;BR /&gt;echo "ok"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;# ./mywaiter&lt;BR /&gt;pid=10614/10615 executing -- please wait..............................ok&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;# head -3 /tmp/sh.10614&lt;BR /&gt;pass_1&lt;BR /&gt;pass_2&lt;BR /&gt;pass_3&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 07 May 2008 18:53:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/wait-output-in-a-script/m-p/4193494#M91381</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-05-07T18:53:41Z</dc:date>
    </item>
  </channel>
</rss>

