Sponsored Content
Full Discussion: Input value changing into 0
Top Forums Shell Programming and Scripting Input value changing into 0 Post 302772149 by MattyV on Saturday 23rd of February 2013 02:00:16 PM
Old 02-23-2013
OK I think I know what's up...

From the READ manual...

Code:
If count is zero, read() returns zero and has  no  other  results.   If
       count is greater than SSIZE_MAX, the result is unspecified

Also I did a little test...

Code:
cat test.txt

[ASD_HAGDF_CSAS_CMPPRD.s_PRDPR_STNNSTN_CSAS_SRCTPP_COMMHIST006_INC_dat_LD]
[bla.bla]
 [bla.bla] [bla.bla]
\[bla.bla\]
No.Brackets.Bla.Bla
[NO_PERIODS]
[NO.UNDERSCORE]

my results using bash with the debug option....
Code:
#!/bin/bash
while read myline
do
echo $myline 
done < test.txt
+ read myline
+ echo a
a
+ read myline
+ echo a b
a b
+ read myline
+ echo a b a b
a b a b
+ read myline
+ echo a b
a b
+ read myline
+ echo No.Brackets.Bla.Bla
No.Brackets.Bla.Bla
+ read myline
+ echo '[NO_PERIODS]'
[NO_PERIODS]
+ read myline
+ echo '[NO.UNDERSCORE]'
[NO.UNDERSCORE]
+ read myline
+ echo

+ read myline

So I think what happens is that the ^[ or [bl la] is being interpreted as a type of non ASCII character. When I tranpose the brackets on either side of your original string...it shows up...

Code:
#!/bin/bash
while read myline
do
echo $myline 
done < test.txt
+ read myline
+ echo a
a
+ read myline
+ echo a b
a b
+ read myline
+ echo a b a b
a b a b
+ read myline
+ echo a b
a b
+ read myline
+ echo No.Brackets.Bla.Bla
No.Brackets.Bla.Bla
+ read myline
+ echo '[NO_PERIODS]'
[NO_PERIODS]
+ read myline
+ echo '[NO.UNDERSCORE]'
[NO.UNDERSCORE]
+ read myline
+ echo ']ASD_HAGDF_CSAS_CMPPRD.s_PRDPR_STNNSTN_CSAS_SRCTPP_COMMHIST006_INC_dat_LD['
]ASD_HAGDF_CSAS_CMPPRD.s_PRDPR_STNNSTN_CSAS_SRCTPP_COMMHIST006_INC_dat_LD[
+ read myline

I would use a different manner of backing up...
 

10 More Discussions You Might Find Interesting

1. Programming

Changing stdin from file redirection to console input

Hi I am doing file redirection at console for use by my binary. %console%> bin &lt inputfile After reading in the entire file, I want my program to continue taking input from the console. So essentially I want to redirect stdin back to console. But I cant figure out how to do it. I am... (4 Replies)
Discussion started by: nauman
4 Replies

2. Shell Programming and Scripting

How to prompt for input & accept input in ONE line

hi, am a new learner to shell programming. i have a script which will prompt for user to key in their name & display their name afterwards. script ===== echo "Pls enter your name:" read name echo "Your name is $name." output ===== Pls enter your name: Bob Your name is Bob. what... (2 Replies)
Discussion started by: newbie168
2 Replies

3. Shell Programming and Scripting

Changing userID and Changing group and GID

Hello, I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job. linux1 linux2 linux3 linux4 linux5 ...... . . . . . 1.) How can i enter "password" in script rather asking me? I was trying this... ssh... (2 Replies)
Discussion started by: deal732
2 Replies

4. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

5. UNIX for Dummies Questions & Answers

send output of a file as input for changing date

Hi, Please help me out on this one. I want to send the output of a file as input for changing the date using date command. Example, i have a file date.txt whose contents are 081014462009 I need to use the date in that file as input for date command. I tried cat date.txt | date ; but it... (2 Replies)
Discussion started by: foxtron
2 Replies

6. Shell Programming and Scripting

Create Multiple files by reading a input file and changing the contents

Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me . Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer. I want to create a mutiple output files with each file having a... (2 Replies)
Discussion started by: bhargavkr
2 Replies

7. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

8. Shell Programming and Scripting

function terminating if i give input as space or no input and enter

HI i have written a script to ask input from the user. this script should promote the user for y/n input. if user enters anyother input then y/n the script promotes him again. this below code is working fine for all the cases. except for space and enter " if i give space and enter it is... (2 Replies)
Discussion started by: BHASKARREDDY006
2 Replies

9. UNIX for Dummies Questions & Answers

Getting input and changing variable?

Hi I am new to scripting and have a function in my .sh script file that outputs a html radio button form weather_forecast_config() { echo "" echo "<html><head><title>Welcome</title></head>" echo "<body>" echo "<h2>Weather Forecast - Change City</h2>" echo "<form name="input"... (5 Replies)
Discussion started by: scriptnewbie
5 Replies

10. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 07:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy