Total Newbie Question...

Reply

Join Date: Aug 2008
Posts: 1
Reputation: MSmith78 is an unknown quantity at this point 
Solved Threads: 0
MSmith78 MSmith78 is offline Offline
Newbie Poster

Total Newbie Question...

 
0
  #1
Aug 8th, 2008
Good day everyone. I'm completely new to scripting. I'm trying to practice in it. I'm using Bash on a SuseLinux 10.3 box. I want to practice by sort of creating my own simple IP Monitoring app that will notify me when somethings down.

That said, here's my first simple but seemingly impossible obstacle.

I have found and understand how to redirect a command's output to a file. For instance, ./fping 10.1.1.23 > test.

That works and I appreciate that. But what about if I want to send the return to a variable for processing instead? How do I do this?

I tried ./fping 10.1.1.23 > $test and then, on the second line, echo $test, but this did not work. It told me that it was an ambiguous redirect.

Thank you for any help you can provide.

Mark
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Total Newbie Question...

 
0
  #2
Aug 8th, 2008
Use back quotes
a=`ls`
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Total Newbie Question...

 
0
  #3
Aug 9th, 2008
Also, if it helps, your original redirect

>$test

was a redirect to value of the variable test, which may not have been defined, giving you the ambiguous redirect error. In most shell languages, use

variable (when defining the variable)

and

$variable (when you want to access its value)

Best wishes,

Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC