Sponsored Content
Top Forums Shell Programming and Scripting Using telnet in my shell script Post 302837969 by umarsatti on Sunday 28th of July 2013 06:01:22 AM
Old 07-28-2013
Using telnet in my shell script

Hello Guys,

I have a linux server where I already logged in, once logged in, i telnet to local host using some dedicated port and do some action. This I can easily do manually.

Since I need to fire a lot requests so I would like to optimize it using a shell script to avoid telnetting each time and do the arduous manual actions, can some body assist me, how to fire a request after triggering telnet in the script. Please note after i telnet to local host i don't need to give any user password.

Below is what I am doing manually which i want to optimize.

Code:
telnet localhost <port>

<I will paste my xml Request here>
<Response will come>

I.e:
Code:
telnet localhost 1111
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

POST /Air HTTP/1.1
Connection: close
User-Agent: UGw Server/4.3/1.0
Authorization: Basic ZmRzdXNlcjpmZHN1c2Vy
Host: 1.1.1.1:1111
Content-Length: 775
Content-Type: text/xml; charset=utf-8

<methodCall>
<methodName>GetBalanceAndDate</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>originNodeType</name>
<value>
<string>EXT</string>
</value>
</member>
<member>
<name>originHostName</name>
<value>
<string>xyz</string>
</value>
</member>
<member>
<name>originTransactionID</name>
<value>
<string>20130315174659200</string>
</value>
</member>
<member>
<name>originTimeStamp</name>
<value>
<dateTime.iso8601>20130315T17:46:59+0000</dateTime.iso8601>
</value>
</member>
<member>
<name>subscriberNumberNAI</name>
<value>
<i4>1</i4>
</value>
</member>
<member>
<name>subscriberNumber</name>
<value>
<string>0101010101</string>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>

Would be greatful if somebody help me to kick start my script.

THanks!!
Umar

Last edited by Scott; 07-28-2013 at 07:24 AM.. Reason: Code tags, please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

telnet & su in shell script

Hi, Any scripting experts out there that can point me to the right direction of writing a script using telnet and su to access a server without any users interaction such as login and entering passwd. Thanks. Thanks in advance vastare (1 Reply)
Discussion started by: vastare
1 Replies

2. Shell Programming and Scripting

telnet shell script on red hat 9 cmd line only

i would like to make a shell script (red hat 9 cmd line only) to telnet to my local isp's webmail server on port 25 and send it commands such as helo :) help would be much appreciated, and i found no posts similar that answered my question... the closest i've gotten to an answer from about 8... (3 Replies)
Discussion started by: kypeswith
3 Replies

3. Solaris

using shell script to telnet

I would like to log into a server read a certain file and get the results back. I have tried like below to no avail; #!/bin/ksh -x ( sleep 2 echo sdpuser sleep 2 echo cs3reloaded sleep 5 cd /export/home/scripts/daily_checks sleep 5 head daily_check_report.txt > test160108.txt exit )... (6 Replies)
Discussion started by: ricky katix
6 Replies

4. Shell Programming and Scripting

usage of telnet in shell script

Hi All, How could I use telnet to connect to Primary Host in the below shell script: Could I use: ( echo user sleep 2 echo password sleep 2 echo "ls ~" sleep 2 echo "exit" ) | telnet hostname ... (1 Reply)
Discussion started by: a1_win
1 Replies

5. Shell Programming and Scripting

closing a telnet session on error, in a shell script

I am using a shell script to telnet into a remote unix server and execute certain commands. But if any command being executed remotely, throws an error, the script just hangs. And the telnet session does not get closed. I want to be able to close the session and complete the script execution in... (1 Reply)
Discussion started by: farahzaiba
1 Replies

6. Shell Programming and Scripting

How to Create a shell script to test the telnet connection status

Hi friends, I'm newbie to shell script. I wanted to create a shell script which able to write a result for all the telnet connection status. For example, from this machine I want to test the telnet connection (total 100+ servers) with this machine. Any idea how to write this shell script?... (16 Replies)
Discussion started by: yhcheong
16 Replies

7. Shell Programming and Scripting

Telnet using shell script

Hi I need to telnet a device with IP Address and port. After logging in, I need to execute some commands in that device. Please find the example below telnet 170.10.11.1 2100 #170.10.11.1 is the IP address. 2100 is the Port after telnet, the device will show the command prompt as : ... (2 Replies)
Discussion started by: sudharsan23
2 Replies

8. UNIX for Advanced & Expert Users

Telnet from shell script , further need to logout if log in not authenticate

Using unix shell script file I need to telnet to a IP further send a command to the telnet IP and get the response to a file with out using "expect" utility and I have achieved this by below command. (sleep 3; echo admin; sleep 3; echo mypass; sleep 5;echo "show status-list"; sleep 5; echo... (3 Replies)
Discussion started by: raghunath Rao
3 Replies

9. UNIX for Dummies Questions & Answers

Shell Script to test telnet connection using port

Hello, I need to test telnet connections using port number for few hosts. Could you please help me? Thanks !! (1 Reply)
Discussion started by: skhichi
1 Replies

10. Shell Programming and Scripting

Need shell script for SMS via telnet command

I am not very much familiar with telnet based scripting so I would need your help to directly submitting sms as deliver_sm or submit_sm msg to SMSC (IP & system_id and password are already known). So, need your help to provide such script. I previously used such script but my harddisk crashed and... (1 Reply)
Discussion started by: wasay
1 Replies
Regexp::Common::URI::telnet(3)				User Contributed Perl Documentation			    Regexp::Common::URI::telnet(3)

NAME
Regexp::Common::URI::telnet -- Returns a pattern for telnet URIs. SYNOPSIS
use Regexp::Common qw /URI/; while (<>) { /$RE{URI}{telnet}/ and print "Contains a telnet URI. "; } DESCRIPTION
$RE{URI}{telnet} Returns a pattern that matches telnet URIs, as defined by RFC 1738. Telnet URIs have the form: "telnet:" "//" [ user [ ":" password ] "@" ] host [ ":" port ] [ "/" ] Under "{-keep}", the following are returned: $1 The complete URI. $2 The scheme. $3 The username:password combo, or just the username if there is no password. $4 The username, if given. $5 The password, if given. $6 The host:port combo, or just the host if there's no port. $7 The host. $8 The port, if given. $9 The trailing slash, if any. REFERENCES
[RFC 1738] Berners-Lee, Tim, Masinter, L., McCahill, M.: Uniform Resource Locators (URL). December 1994. SEE ALSO
Regexp::Common::URI for other supported URIs. AUTHOR
Damian Conway (damian@conway.org) MAINTAINANCE
This package is maintained by Abigail (regexp-common@abigail.be). BUGS AND IRRITATIONS
Bound to be plenty. LICENSE and COPYRIGHT This software is Copyright (c) 2001 - 2009, Damian Conway and Abigail. This module is free software, and maybe used under any of the following licenses: 1) The Perl Artistic License. See the file COPYRIGHT.AL. 2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2. 3) The BSD Licence. See the file COPYRIGHT.BSD. 4) The MIT Licence. See the file COPYRIGHT.MIT. perl v5.18.2 2013-03-08 Regexp::Common::URI::telnet(3)
All times are GMT -4. The time now is 04:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy