1753386 Members
6069 Online
108792 Solutions
New Discussion юеВ

Re: typeset question?

 
RAC_1
Honored Contributor

Re: typeset question?

typeset -i is for intergersonly. You are entering the intergers. Just read something will do.
There is no substitute to HARDWORK
Bill Hassell
Honored Contributor

Re: typeset question?

As mentioned, typeset -i is for a single integer. When you entered the dots for an IP address, typeset failed because the dot is illegal for an integer. You need to read your input as a string, then parse the string into the 4 numbers. You could also do this with IFS but this is more complex. Do you want the result of the 4 numbers to be converted into an integer?


Bill Hassell, sysadmin
lnl
Occasional Advisor

Re: typeset question?

Bill,

I want it to read numbers only with dots and then echo the full input. That's all.

Any examples?
Bill Hassell
Honored Contributor

Re: typeset question?

You can do this:

print "Enter numbers? \c"
read
echo "$REPLY"

The read statement reads everything on the line and if no variable is specified, then everything is assigned to REPLY. You use a variable with mixed characters by surrounding it with double quotes.


Bill Hassell, sysadmin
Muthukumar_5
Honored Contributor

Re: typeset question?

Simply use without typeset -i input setting.

print "Enter numbers? \c"
read input > /dev/null 2>&1
echo $input

--
Muthu
Easy to suggest when don't know about the problem!
lnl
Occasional Advisor

Re: typeset question?

thanks