FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-12-2009, 02:00 AM
Neil Cherry
 
Default Supressing an error message in bash script

On 12/11/2009 09:40 PM, Ray Parrish wrote:
> function ArrayLoad {
> PackageData=`"dpkg -p gedit"` 2> /dev/null

Try it without the double quotes. Does that do what you want?


--
Linux Home Automation Neil Cherry ncherry@linuxha.com
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-12-2009, 02:23 AM
Ray Parrish
 
Default Supressing an error message in bash script

Neil Cherry wrote:
> On 12/11/2009 09:40 PM, Ray Parrish wrote:
>
>> function ArrayLoad {
>> PackageData=`"dpkg -p gedit"` 2> /dev/null
>>
>
> Try it without the double quotes. Does that do what you want?
>
Wirhout the double quotes nothing gets loaded into the array.. Also
nothing gets loaded into the array with my original code, as the output
thst I thought ewas being generated by that function, was actually being
output by the following function which works very nicely. I had
forgotten to comment out it's call in my test code so it was generating
the loop output before the only output of the first function I quoted
which was the error message.

# Test array assignment from variable line by line
function ReadintoArray {
PackageData=`dpkg -p gedit`
LoopCount=0
while read ThisLine; do
Data[$LoopCount]="$ThisLine"
echo "$LoopCount - ${Data[$LoopCount]}"
(( LoopCount++ ))
done <<<"$PackageData"
}

I guess I'll go with this second version which works great, unless
someone can tell me how to load the array with a single call like I was
trying in the other function. Just looking for the most efficient way to
get the data into the array line by line.

Later,Ray Parrish


--
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-12-2009, 02:43 AM
Neil Cherry
 
Default Supressing an error message in bash script

On 12/11/2009 10:23 PM, Ray Parrish wrote:
> Neil Cherry wrote:
>> On 12/11/2009 09:40 PM, Ray Parrish wrote:
>>
>>> function ArrayLoad {
>>> PackageData=`"dpkg -p gedit"` 2> /dev/null
>>>
>>
>> Try it without the double quotes. Does that do what you want?
>>
> Wirhout the double quotes nothing gets loaded into the array.. Also
> nothing gets loaded into the array with my original code, as the output
> thst I thought ewas being generated by that function, was actually being
> output by the following function which works very nicely. I had
> forgotten to comment out it's call in my test code so it was generating
> the loop output before the only output of the first function I quoted
> which was the error message.
>
> # Test array assignment from variable line by line
> function ReadintoArray {
> PackageData=`dpkg -p gedit`
> LoopCount=0
> while read ThisLine; do
> Data[$LoopCount]="$ThisLine"
> echo "$LoopCount - ${Data[$LoopCount]}"
> (( LoopCount++ ))
> done <<<"$PackageData"
> }
>
> I guess I'll go with this second version which works great, unless
> someone can tell me how to load the array with a single call like I was
> trying in the other function. Just looking for the most efficient way to
> get the data into the array line by line.

After I sent the message I notice a number of problems. I'm not
familiar with arrays and without the quotes there's no array.

Sorry

--
Linux Home Automation Neil Cherry ncherry@linuxha.com
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-12-2009, 11:41 AM
Neil Cherry
 
Default Supressing an error message in bash script

On 12/11/2009 10:23 PM, Ray Parrish wrote:
> Neil Cherry wrote:
>> On 12/11/2009 09:40 PM, Ray Parrish wrote:
>>
>>> function ArrayLoad {
>>> PackageData=`"dpkg -p gedit"` 2> /dev/null
>>>
>>
>> Try it without the double quotes. Does that do what you want?
>>
> Wirhout the double quotes nothing gets loaded into the array.. Also
> nothing gets loaded into the array with my original code, as the output
> thst I thought ewas being generated by that function, was actually being
> output by the following function which works very nicely. I had
> forgotten to comment out it's call in my test code so it was generating
> the loop output before the only output of the first function I quoted
> which was the error message.
>
> # Test array assignment from variable line by line
> function ReadintoArray {
> PackageData=`dpkg -p gedit`
> LoopCount=0
> while read ThisLine; do
> Data[$LoopCount]="$ThisLine"
> echo "$LoopCount - ${Data[$LoopCount]}"
> (( LoopCount++ ))
> done <<<"$PackageData"
> }
>
> I guess I'll go with this second version which works great, unless
> someone can tell me how to load the array with a single call like I was
> trying in the other function. Just looking for the most efficient way to
> get the data into the array line by line.
>
> Later,Ray Parrish
>
>

function ReadintoArray {
LoopCount=0
dpkg -p gedit | while read line
do
echo "$LoopCount - $line"
(( LoopCount++ ))
done
}

How about the above? If I tried it your way I ended up with each
word as an array element. To fix that I could have changed the IFS
to use only a
(but I was lazy). So went the read route.

--
Linux Home Automation Neil Cherry ncherry@linuxha.com
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 07:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org