A variable within a loop doesnt get updated - eventhough the 'inputfile' changes.
I have a tempfile ($TMP.playstatus), which contains this data:
Where constantly a new line is appended.
I have this semi working:
Deleted stuff (previous tries):
Regardless of what i try, the $CUR-value is read properly only the first time - so it seems to me, but afterwards it remains the same/doesnt change...
As in, beeing spamed with:
OR, almost the same:
To my understanding the variable $CUR should be updated just before its echo'd within each loop.
Any advice/ideas please?
Thank you in advance
---------- Post updated at 11:14 ---------- Previous update was at 10:38 ----------
Maybe this different output helps:
Outputs as:
Since the background job is told to redirect its output to $STATUS i thought after the cleaning the new lines would still be added.
Even when i DELETE the tempfile ($STATUS), it doesnt read a value while the files doesnt exist, and after... it jumps back to the first value (0.01), as if its 0.01 was even on the lowest line...
In your first sample the sleep statement is missing, which is essential in this situation, otherwise the script checks uncontrolled number of time per second and unnecessarily strains the processor core...
In your 2nd sample the background job does not redirect its output to $STATUS.
means truncate file "$STATUS", which empties the file, without deleting it.
---
Also, it is unusual to redirect output to /dev/zero, which is an input device, consider using /dev/null instead..
Last edited by Scrutinizer; 05-31-2015 at 04:19 PM..
I can't reproduce that. Producing your temp file in background, and running your semi-working script snippet, I get
What you should NOT do is redirect your stdout into your input file (reading from and redirecting into $STATUS), be it written by another process or not. If not, you'll erase it and then read only the lines back that have just been written by yourself. If written, you'll get a random mixup of lines by yourself and lines by the other process (what seems to be your sample output).
---------- Post updated at 21:54 ---------- Previous update was at 21:45 ----------
You can help me with a hint/trick: How did you get those <TAB> chars into the code text?
You can help me with a hint/trick: How did you get those <TAB> chars into the code text?
If you copy text containing <tab> characters, paste it into a message editing window on this site, and put CODE or ICODE tags around the pasted text, the <tab>s will be preserved.
Note, however, that if you copy text out of a vi editing window, you won't be copying <tab> characters because vi (and vim and other clones) display <space>s on the editing window instead of depending on currently set tab stops. But, if you cat the edited code to your screen and copy the cat output, the <tab>s will be preserved.
OK, i guess we're getting closer.. while its playing in the background, i tried to read the status file manualy:
But i just cant explaing the differende ?!
'Funny' thing is, with grep, it prints all the vars on a single line, and on the manual check, i see them prints over each other.
Inside the script function, the grep filtering causes a 'freeze', it keeps playing, but the code stucks at grep.
Eg:
I'd expect for each and every single 'line' here the behaviour RudiC reports
Just installed the latest version on my hp stream, was tired of windows. Of the few times I've used Linux, this is the first time it won't update. Im connected to the net the updater recognizes that the OS needs 21 updates. But it won't download/install the updates. It also won't load the... (1 Reply)
I have an app in FP26 with 400 prgs currently en UW7.1.1 thats work perfectly.
I have a new server and install UW7.1.4 and FP26. Then I had copy my App to new server. But the next command doesn't work:
use database
@10,10 get name
read
I can't write in the get.
... (5 Replies)
Hello Expert,
is there any command through which i can update/replace the folder after every two months.
lets say i have folder
/usr/local/x_folder
created on 01/01/2011
I need to update it on 31/03/2011
Please help me to get the logic :confused:
Thanks (3 Replies)
Hello
I have a server whose os level reads 5300-01-00-0000. It has to be upgraded to the latest level which is 5300-12-04-1119. What would I need to do go get the server to this point? Would I need to go through each patch level until I get it to current? If so, would anyone happen to know... (1 Reply)
hi,
I'm trying to add a # to the beginning of the line where the a word is included.
and the i want to run the whole original script.
and if possible I would prefer that line would stay in the same order in the text file, the line which includes the word.
Thanks, (10 Replies)
I have an extremely large csv file that I need to search the second field, and upon matches update the last field...
I can pull the line with awk.. but apparently you cant use awk to directly update the file? So im curious if I can use sed to do this... The good news is the field I want to... (5 Replies)
Hello,
I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^
Here is what I'm trying to achieve :
file1:
test filea 3495;
test fileb 4578;
test filec 7689;
test filey 9978;
test filez 12300;
file2:
test filea... (11 Replies)