<?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: Calling Telnet from a Script called from Cron in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259709#M688063</link>
    <description>&lt;!--!*#--&gt;&amp;gt;OldSchool: be aware that it is possible for "file1*.csv" to be different in the two invocations. You might consider storing the result in a variable&lt;BR /&gt;&lt;BR /&gt;Well the variable in question is $file.&lt;BR /&gt;ls file1*.csv | while read file; do&lt;BR /&gt;   ...&lt;BR /&gt;   mv $file /usr/ndm/dir1/Inbound/done/&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&amp;gt;What happens if another process adds "file1abc.csv" after the "ls" runs&lt;BR /&gt;&lt;BR /&gt;If you use $file above, you'll catch it next time.</description>
    <pubDate>Wed, 03 Sep 2008 03:00:51 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2008-09-03T03:00:51Z</dc:date>
    <item>
      <title>Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259689#M688043</link>
      <description>Hey guys,&lt;BR /&gt;Scripting is something rare to non-existent in our environment, so I apologize in advance.&lt;BR /&gt;I've searched several sites, forums etc, but I'm not able to put the 2 and 2 together on this.&lt;BR /&gt;&lt;BR /&gt;What we have is a script that runs at regular intervals and looks for a file in a folder. When the file is there, we have a While/Do that calls a 2nd script that will telnet into itself, and issue keyboard commands (echo) to log in and process the file. &lt;BR /&gt;When fired off manually, the 1st script sees the new file, calls the 2nd script and processes the file perfectly (well it works anyway...LOL).&lt;BR /&gt;When we have the execution ran from the cron process, the log (Cron) doesn't show anything of real value. The 1st script files off, calls the 2nd script but I think I'm missing something, since it doesn't actually run. The first script does finish as it moved the file to the "processed" subfolder. I know this is really basic stuff, but any help is greatly appreciated!&lt;BR /&gt;&lt;BR /&gt;Here is the 2nd script (edited for content):&lt;BR /&gt;&lt;BR /&gt;( echo open myself&lt;BR /&gt;sleep 2&lt;BR /&gt;echo login&lt;BR /&gt;sleep 1&lt;BR /&gt;echo password&lt;BR /&gt;sleep 1 &lt;BR /&gt;echo more commands&lt;BR /&gt;echo log out of application&lt;BR /&gt;) | telnet&lt;BR /&gt;&lt;BR /&gt;I know, I know, color me stupid. Having a real brain fart today.&lt;BR /&gt;&lt;BR /&gt;Thanks a million!!!</description>
      <pubDate>Thu, 28 Aug 2008 12:13:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259689#M688043</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T12:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259690#M688044</link>
      <description>USUALLY when a script runs from the command line, but doesn't from cron the problem is environment related.&lt;BR /&gt;&lt;BR /&gt;You must remember that the environment in cron is very sparse.  Your /etc/profile and ~/.profile do NOT get sourced so any PATH or other environment variables you have when logged in are NOT available.&lt;BR /&gt;&lt;BR /&gt;If you are referencing any variables in your scripts, double check and make sure those variables are defined in the script.</description>
      <pubDate>Thu, 28 Aug 2008 12:19:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259690#M688044</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2008-08-28T12:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259691#M688045</link>
      <description>Thanks Patrick,&lt;BR /&gt;I'm purely passing keystrokes to the telnet session. I'm not using any variables (so far).&lt;BR /&gt;I keep finding data that points to environment as you described, but what would I actually need?</description>
      <pubDate>Thu, 28 Aug 2008 12:27:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259691#M688045</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T12:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259692#M688046</link>
      <description>Without a tty (which you are NOT going to get with a cron job) I am not sure how telnet is going to work.&lt;BR /&gt;&lt;BR /&gt;How about remsh or ssh and supply the commands.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 12:28:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259692#M688046</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2008-08-28T12:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259693#M688047</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Can you tell me how did you set cron entry here...?&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 12:30:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259693#M688047</guid>
      <dc:creator>Deepak Kr</dc:creator>
      <dc:date>2008-08-28T12:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259694#M688048</link>
      <description>Sure thing.&lt;BR /&gt;From the contab -l :&lt;BR /&gt;&lt;BR /&gt;0,5,10,15,20,25,30 12-20 * * * /usr/ndm/tmp/dir/./File1.scr &amp;gt; /usr/ndm/tmp/dir/File1.log&lt;BR /&gt;&lt;BR /&gt;The log files are empty.&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 12:35:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259694#M688048</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T12:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259695#M688049</link>
      <description>The crontab calls this first script:&lt;BR /&gt;&lt;BR /&gt;cd /usr/ndm/dir1/Inbound&lt;BR /&gt;ls file1*.csv | while read file&lt;BR /&gt;do&lt;BR /&gt;/usr/ndm/tmp/dir/./Script2.scr&lt;BR /&gt;mv file1*.csv /usr/ndm/dir1/Inbound/done/&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 12:49:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259695#M688049</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T12:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259696#M688050</link>
      <description>Thanks!!&lt;BR /&gt;&lt;BR /&gt;Can you attach both scripts here...&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 12:54:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259696#M688050</guid>
      <dc:creator>Deepak Kr</dc:creator>
      <dc:date>2008-08-28T12:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259697#M688051</link>
      <description>Do you think that it's moving my files before the telnet session can process them?&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 13:08:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259697#M688051</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T13:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259698#M688052</link>
      <description>Here is script1</description>
      <pubDate>Thu, 28 Aug 2008 13:09:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259698#M688052</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T13:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259699#M688053</link>
      <description>Here is script2</description>
      <pubDate>Thu, 28 Aug 2008 13:09:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259699#M688053</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T13:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259700#M688054</link>
      <description>as Tim noted, remsh, rexec, or better yet ssh is the way to go.  you simply execute the script you want to run.&lt;BR /&gt;&lt;BR /&gt;telnet is gonna have issues, as you don't have a tty when running via cron.</description>
      <pubDate>Thu, 28 Aug 2008 13:50:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259700#M688054</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2008-08-28T13:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259701#M688055</link>
      <description>or there is always the question "Why don't you run the job out of cron on the target machine?"</description>
      <pubDate>Thu, 28 Aug 2008 13:52:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259701#M688055</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2008-08-28T13:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259702#M688056</link>
      <description>Hi Jeff:&lt;BR /&gt;&lt;BR /&gt;I agree with Tim and OldSchool --- you should look at 'remsh' or 'ssh'.  It appears that you are trying to invoke a 'telnet' session simply to provide connectivity to another server and do a simple script involving selecting and renaming some files.  This is what 'remsh' or 'ssh' is designed to offer.&lt;BR /&gt;&lt;BR /&gt;Too, in your first script you have:&lt;BR /&gt;&lt;BR /&gt;/usr/ndm/tmp/dir/./Script2.scr&lt;BR /&gt;&lt;BR /&gt;That makes no sense unless it is a posting error.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 28 Aug 2008 14:04:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259702#M688056</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-28T14:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259703#M688057</link>
      <description>The entry to ..././Script2.scr is where the telnet script is located.&lt;BR /&gt;&lt;BR /&gt;If I used something like ssh, is the format the same as the telnet session? &lt;BR /&gt;If I was able to call the application directly without using telnet, how can I pass the keystrokes? Can I still use Echo and sleep? Does the list of commands need to be in parenthesis?</description>
      <pubDate>Thu, 28 Aug 2008 14:17:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259703#M688057</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T14:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259704#M688058</link>
      <description>Hi (again) Jeff:&lt;BR /&gt;&lt;BR /&gt;Using 'ssh' or 'remsh' could be as simple as this (example) to list files on a remote server:&lt;BR /&gt;&lt;BR /&gt;# ssh remoteboxt 'ls /home/jrf/*.log|while read FILE;do echo ${FILE};done'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 14:50:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259704#M688058</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-28T14:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259705#M688059</link>
      <description>Hey again James,&lt;BR /&gt;&lt;BR /&gt;Thanks a million! I am light years ahead. Only hurdle I have left is passing the password when make the SSH connection. For some reason the echo command isn't passing it. Any ideas?</description>
      <pubDate>Thu, 28 Aug 2008 15:29:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259705#M688059</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T15:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259706#M688060</link>
      <description>Hi (again) Jeff:&lt;BR /&gt;&lt;BR /&gt;Setup SSH public keys.  See Matti's directions in this thread --- he does a nice job of describing the simple procedure:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1254688" target="_blank"&gt;http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1254688&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I'm not sure what you mean by "...the echo command isn't passing".  If you wanted to do:&lt;BR /&gt;&lt;BR /&gt;# ssh remotebox 'ls /home/jrf/*.log|while read FILE;do echo ${FILE} &amp;gt; /var/tmp/results;done'&lt;BR /&gt;&lt;BR /&gt;...then you coult retrieve the results back to your local server with:&lt;BR /&gt;&lt;BR /&gt;# scp remotebox:/var/tmp/results /home/jrf/results&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Aug 2008 15:55:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259706#M688060</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-28T15:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259707#M688061</link>
      <description>Thanks James!&lt;BR /&gt;&lt;BR /&gt;I am at 100% success. &lt;BR /&gt;When I tried to test, I was getting a password prompt, but took your advice and VOILA!&lt;BR /&gt;&lt;BR /&gt;Again, thanks to everyon's feedback, I was not only able to get my problem solved, but learn a ton in the process.</description>
      <pubDate>Thu, 28 Aug 2008 16:24:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259707#M688061</guid>
      <dc:creator>Jeff Murphy</dc:creator>
      <dc:date>2008-08-28T16:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Telnet from a Script called from Cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259708#M688062</link>
      <description>"&lt;BR /&gt;cd /usr/ndm/dir1/Inbound&lt;BR /&gt;ls file1*.csv | while read file&lt;BR /&gt;do&lt;BR /&gt;/usr/ndm/tmp/dir/./Script2.scr&lt;BR /&gt;mv file1*.csv /usr/ndm/dir1/Inbound/done/&lt;BR /&gt;done&lt;BR /&gt;"&lt;BR /&gt;&lt;BR /&gt;"/usr/ndm/tmp/dir/./Script2.scr"  &lt;BR /&gt;As noted previously, this makes no sense.  What do you think the "." represents?  This should probably be something like:&lt;BR /&gt;&lt;BR /&gt;/usr/ndm/tmp/dir/Script2.scr&lt;BR /&gt;As I noted before, typically this would be set up in the a crontab on the "other" machine.  Logging in or rexec'ing or ssh is just more overhead.  It is simple enough to check for the existance of files of that name pattern and procede or not based on those results.  I can see the utility of machineA:scriptA running scriptB on machineB if scriptB depends upon something that scriptA does, but that isn't clear in this case.&lt;BR /&gt;&lt;BR /&gt;In any case, be aware that it is possible for "file1*.csv" to be different in the two invocations.  You might consider storing the result in a variable, and then processing that variable.  &lt;BR /&gt;&lt;BR /&gt;What happens if another process adds "file1abc.csv" after the "ls" runs and before/during Script2.scr's execution.  The "mv" will see fileabc.csv and move it, but it won't have been processed.  Such errors can be a headache to find.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Sep 2008 16:51:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calling-telnet-from-a-script-called-from-cron/m-p/4259708#M688062</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2008-09-02T16:51:15Z</dc:date>
    </item>
  </channel>
</rss>

