LinuxQuestions.org
Help answer threads with 0 replies.
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 06-08-2013, 06:45 AM   #1
Sanpreet Singh
LQ Newbie
 
Registered: Jan 2013
Location: Malout,Punjab
Distribution: Ubuntu(Debian)
Posts: 25
Blog Entries: 1

Rep: Reputation: Disabled
Bash Scripting


I want a help on bash scripting.I am explaining the problem now.

I am reading the output from the serial port(ttyUSB0). Now I want to draw the graph from the readings that I have obtained. The reading are Linked here by me as https://www.facebook.com/photo.php?f...type=3&theater

Now in the above link in one line there are two readings. I want to do caliberation of both the reading. SO from one line how can I make the caliberation of two different readings. How to store these two readings. How the bash will know which reading is from which?

Is there any way to store this values.

I am writing the bash script that has read from the serial port.

#!/usr/bin/bash
cat /dev/ttyUSB0
while true; do
read LINE < /dev/ttyUSB0
echo $LINE
done

Any solution will be most welcomed.
Attached Images
File Type: png TCC_Screen_Shot.png (32.3 KB, 18 views)
 
Old 06-08-2013, 10:27 AM   #2
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,572

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Well I am not sure I follow, but why not just read the values into 2 variables?
Code:
while read -r var1 var2
do
   ...
done</dev/ttyUSB0
 
Old 06-09-2013, 08:04 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949
As grail said.

How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?
http://mywiki.wooledge.org/BashFAQ/001

BTW, "/usr/bin/bash"? In nearly all cases shell interpreters are kept in /bin. Unless you have some different version installed that you want to use instead?

And please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques. Thanks.
 
  


Reply


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
bash scripting and tr zunder1990 Linux - Newbie 11 03-15-2011 02:39 PM
Bash Scripting for TC CraigAaron Programming 3 03-02-2011 06:24 PM
bash scripting ZAMO Linux - General 1 12-04-2008 02:53 AM
Reading a bash variable in bash scripting problem freeindy Programming 3 11-27-2008 02:29 AM
bash scripting -=MaGo=- Programming 16 08-30-2003 07:07 PM


All times are GMT -5. The time now is 07:24 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