LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-12-2011, 12:15 PM   #1
mirzasoltan
LQ Newbie
 
Registered: Oct 2010
Posts: 28

Rep: Reputation: 0
problem with telnet


hi everyone
i write this script:
-----------------------------
#!/bin/bash
echo "Welcome"
while true
do
echo "please enter 2 numbers: "
read -r A B
echo your numbers is $A and $B
echo $(($A+$B))
done
------------------------------
i make this script to become a service ( i test it from bash, and my script work good), my problem is when i telnet to my local host (127.0.0.1) via a personal port like 5555 telnet give this error: ")syntax error: invalid arithmetic operator (error token is ", i know this error is for echo $(($A+$B)) and i know that telnet can not calculate $A+$B and the error is for this, but i want a solution for this problem, any suggestion...
 
Old 02-12-2011, 12:37 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
telnet? This has nothing whatsoever to do with telnet. How are you using telnet with this? something messy with xinetd? Unless you are actually connecting to a telnet server, then this is not about telnet.
 
Old 02-12-2011, 12:56 PM   #3
mirzasoltan
LQ Newbie
 
Registered: Oct 2010
Posts: 28

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by acid_kewpie View Post
telnet? This has nothing whatsoever to do with telnet. How are you using telnet with this? something messy with xinetd? Unless you are actually connecting to a telnet server, then this is not about telnet.

first i write this script
then make this service file under the /etc/xinetd.d/filename:

service service-test
{
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/service-test
port = 5555
}

then add my personal port like 5555 to /etc/services file
then open this port in iptables (firewall)
at last i telnet to my local host to test this service:
telnet 127.0.0.1 5555

then its prompt me to give it two numbers (echo "please enter 2 numbers: ")
but when i type two numbers and push enter button, (script continue) in line echo $(($A+$B)) that error appear, i used set -x and i found the line that gives error, and i know this is because of sum two numbers line.

any suggestion?
 
Old 02-12-2011, 02:13 PM   #4
ChrisAbela
Member
 
Registered: Mar 2008
Location: Malta
Distribution: Slackware 14.1
Posts: 467

Rep: Reputation: 89
I tried your script on Slackware on a telnet session and it works.

Will you post the output of:
Quote:
$-
for normal and telnet sessions?
 
  


Reply

Tags
bash scripting, telnet


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to telnet to Linux Host inspite of installing telnet-server RPM - Need Help sinamdar Linux - Software 7 04-11-2009 07:09 AM
Can't end telnet servcie in xinetd when close remote telnet cliend forcely zeroneworld Linux - Newbie 2 12-09-2007 08:47 PM
Can't end telnet servcie in xinetd when close remote telnet cliend forcefully. zeroneworld Linux - General 1 12-06-2007 07:17 AM
Running Telnet in a script, want to save Telnet output, howtodothis??? anil3 Linux - Software 2 03-08-2006 04:01 PM


All times are GMT -5. The time now is 08:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration