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, 01:40 AM
Ray Parrish
 
Default Supressing an error message in bash script

Hello,

I have the following code -

# This is a test of whether I can load an array line by line from a
command's output, instead of word by word.
function ArrayLoad {
PackageData=`"dpkg -p gedit"` 2> /dev/null
LoopCount=0
while [[ LoopCount < ${#PackageData} ]]; do
echo "$LoopCount - ${PackageData[$LoopCount]}"
(( LoopCount++ ))
done
}

Which outputs the following.-

ray@RaysComputer:~$ /home/ray/Bashscripts/TestScriptlet.sh
0 - Package: gedit
1 - Priority: optional
2 - Section: gnome
3 - Installed-Size: 2688
4 - Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
5 - Architecture: i386
6 - Version: 2.22.3-0ubuntu2
7 - Replaces: gedit-common (<< 2.16.2-3)
8 - Depends: gconf2 (>= 2.10.1-2), gedit-common (>= 2.22), gedit-common
(<< 2.23), iso-codes, libatk1.0-0 (>= 1.20.0), libattr1 (>= 2.4.4-1),
libc6 (>= 2.4), libcairo2 (>= 1.6.0), libenchant1c2a, libgconf2-4 (>=
2.13.5), libglade2-0 (>= 1:2.6.1), libglib2.0-0 (>= 2.16.0), libgnome2-0
(>= 2.17.3), libgnomeui-0 (>= 2.17.1), libgnomevfs2-0 (>= 1:2.17.90),
libgtk2.0-0 (>= 2.12.0), libgtksourceview2.0-0 (>= 2.2.0),
liblaunchpad-integration1 (>= 0.1.17), libpango1.0-0 (>= 1.20.5),
libx11-6, libxml2 (>= 2.6.27), python, python-glade2 (>= 2.9.7),
python-gobject (>= 2.11.5), python-gtk2 (>= 2.9.7),
python-gtksourceview2 (>= 2.2.0), python-support (>= 0.7.1), python2.5
(>= 2.5), scrollkeeper
9 - Recommends: libgnomevfs2-bin, python-gnome2, zenity
10 - Conflicts: gedit-common (<= 2.10.5-1)
11 - Size: 735948
12 - Description: official text editor of the GNOME desktop environment
13 - gedit is a text editor which supports most standard editor features,
14 - extending this basic functionality with other features not usually
15 - found in simple text editors. gedit is a graphical application which
16 - supports editing multiple text files in one window (known sometimes as
17 - tabs or MDI).
18 - .
19 - gedit fully supports international text through its use of the Unicode
20 - UTF-8 encoding in edited files. Its core feature set includes syntax
21 - highlighting of source code, auto indentation and printing and
print preview
22 - support.
23 - .
24 - gedit is also extensible through its plugin system, which currently
25 - includes support for spell checking, comparing files, viewing CVS
26 - ChangeLogs, and adjusting indentation levels.
27 - .
28 - Homepage: http://www.gnome.org/projects/gedit/
29 - Original-Maintainer: Debian GNOME Maintainers
<pkg-gnome-maintainers@lists.alioth.debian.org>
/home/ray/Bashscripts/TestScriptlet.sh: line 377: dpkg -p gedit: command
not found
ray@RaysComputer:~$

So it works the way I want it to, except for being able to suppress the
error message about 'command not found' at the end. I thought "2>
/dev/null" was the standard way to send an error message to oblivion,
but it's not working. Can someone tell me the right way to suppress the
error message?

I've also just tried -

PackageData=`"dpkg -p gedit 2> /dev/null"`

Which also outputs the error message.

Thanks, 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
 

Thread Tools




All times are GMT. The time now is 01:36 AM.

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