Can't get While loop working with rrdtool update


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can't get While loop working with rrdtool update
# 1  
Old 11-23-2012
Can't get While loop working with rrdtool update

I have data in a CSV file that looks like;
Code:
1353557880:1.111:123.3
1353557940:1.113:123.3
1353558000:1.118:123.3
1353558060:1.123:123.3
1353558120:1.218:123.3

I'm running the following;
Code:
while IFS=":" read d a b; do rrdtool update temp.rrd $d:$a:$b; done <temp6

It gives me the following error for each data line;
Code:
' to float not complete: tail ''123.3

If I echo the line it prints fine and if I manually type what was echoed it works fine. It appears that when running in the "while" loop it wants the data in floating point? The "$a" variable works fine and if I replace the "$b" variable with a U for undefined the script will work. I've tried several things, even just using one read variable, still doesn't work.

Anyone got any ideas?

Last edited by Franklin52; 11-23-2012 at 03:13 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 11-23-2012
Seems a problem of Windows-style line-terminators (CR-LF combination).
Run dos2unix on the file first.
If you don't have this utility, use tr -d '\r' < infile > new_infile.

Last edited by elixir_sinari; 11-23-2012 at 03:05 AM..
# 3  
Old 11-23-2012
Figured out what was causing the problem. The CSV file has some hidden characters at the end. I was able to strip them off using grep and now it works.

---------- Post updated at 02:14 AM ---------- Previous update was at 02:07 AM ----------

Didn't re-fresh my screen soon enough, you are correct elixir, it probably is the line terminators. I used the grep command;
Code:
grep -o '..........:.....:.....' infile >outfile

This strips off any extra characters but the tr command looks more straight forward.
Thanks,

Last edited by Franklin52; 11-23-2012 at 03:16 AM.. Reason: Please use code tags for data and code samples
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Update a database table in a for loop

Im trying to update an informix database table for each occurance of a head_barcode in a file called mw within a for loop please see below - cant get the syntax correct. any help please? for a in `cat /tmp/mw` do sql image - << STOP > /dev/null 2>&1 update doc_table set status =... (4 Replies)
Discussion started by: worky
4 Replies

2. Shell Programming and Scripting

Python-rrdtool try except rrdtool.error module object has no attribute error

I have this code that gives this error on Linux and will be grateful if you can help import rrdtool try: ret_asd = rrdtool.update(myfile.rrd,'N:%s:%s' %(metric1, metric2)); except rrdtool.error, e: print e When i run the above i get the below error except... (1 Reply)
Discussion started by: kaf3773
1 Replies

3. Shell Programming and Scripting

For-loop not working

Hello all, I would like to unzip some files with a for-loop. Is there anyone who could tell me how I should do this - in a correct way? for file in $(ls); do echo gzip -d < $file | tar xf -; done The problem is the pipe - I believe. But how could I do it? I need it for the command... (4 Replies)
Discussion started by: API
4 Replies

4. Shell Programming and Scripting

Python update variable name in for loop

Hello all, Not sure if this question has been answered already. I have some xml Element variable as below: child19 = core_elem_dcache.find('stat') child20 = core_elem_dcache.find('stat') child21 = core_elem_dcache.find('stat') child22 = core_elem_dcache.find('stat'Next I... (2 Replies)
Discussion started by: Zam_1234
2 Replies

5. SuSE

Yum update not working from spacewalk server

Hello, I have registered an SLES11SP1 server with my spacewalk server however when I perform a 'yum repolist', I do not see my spacewalk server as one of the available repositories. So when I perform yum update (any-package), it does not find an update available. HOwever within the Spacewalk GUI... (3 Replies)
Discussion started by: s ladd
3 Replies

6. Shell Programming and Scripting

using Perl with rrdtool to create and update graphs

Hi guys, im having real difficulty getting my head around perl and rrdtool and was hoping someone could help I want to run a perl script from cron which retrieves the data every 5 mins, creates .rrd's if not already created, and updates the DS from the reultsHash or $key, then creates the... (2 Replies)
Discussion started by: jeffersno1
2 Replies

7. Solaris

Update Manager Not Working

Hello I reinstalled my OS today and after going through the registration the updatemanager pops up, as expected. The problem is all i get is an error message box that's completely blank. The icon in the sytem tray is a blue question mark and when hovering over it, it says i'm not... (4 Replies)
Discussion started by: jpg.2009
4 Replies

8. UNIX for Advanced & Expert Users

oracle update not working

Hi, I have a oracle source with a field my_date =06/02/2009 I am trying to update the table to SYSDATE with a myscript.sql where I have UPDATE table set my_date=to_DATE(SYSDATE,'MM/DD/YYYY'); Now I try to run it with myupdate.SH script where I have sqlplus nolog @myscript.sql ... (4 Replies)
Discussion started by: RubinPat
4 Replies

9. UNIX for Advanced & Expert Users

Pro*C Update not working from Crontab

Dear All, I have writen a Pro*c program that does a data base select,insert,update statements and I have scheduled the program to run from crontab, It is runing fine for the select insert and commit statement till it reaches the update statement , it throws the following error: SQL On IPB... (2 Replies)
Discussion started by: alhallay
2 Replies

10. UNIX for Dummies Questions & Answers

apt-get update not working

Hi all, Till now i was able to do apt-get update. but today i started to the following error: # apt-get update E: Could not open lock file /var/lib/apt/lists/lock - open (2 No such file or directory) E: Unable to lock the list directory # Could any one let me know how to solve it. ... (1 Reply)
Discussion started by: gauri
1 Replies
Login or Register to Ask a Question