Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-14-2004, 11:17 AM   #1
Registered: Feb 2004
Location: Belgium
Distribution: Suse 9.1 Pro / Gentoo
Posts: 114

Rep: Reputation: 15
grep acting strange in script

I'm writing a for my wireless card to be able to switch easy between networks and connect to them. The script it self is working fine but after the connection i want to output a "status raport" of the network connection.
One of the things i wanted to report was the ip but as soon as i us a grep command it acts strange and doesn't give any output. I've tryed the commands themself in the shell and they all work but as soon as i try them form the script it fails

IP=`/sbin/ifconfig wlan0 | grep inet | cut -d: -f2 | cut -d' ' -f1`
echo $IP

this works in the shell but not in the script

Does anybody now why and how i can fix this.
Old 12-14-2004, 11:29 AM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 34
It sounds like the problem is above the grep code.
stdout/stderr is being redefined or doesn't exist.
Old 12-14-2004, 12:15 PM   #3
Registered: Feb 2004
Location: Belgium
Distribution: Suse 9.1 Pro / Gentoo
Posts: 114

Original Poster
Rep: Reputation: 15
OK found the problem, it has nothing to do with 'grep'.
Just a stupid mistake, is started dhcpcd but emediatly after that i tryed to get the ip but the DHCP request hasn't been completed at that time so the grep inet won't return anything.
No i first sleep for a few seconds and then i can get the ip.


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
partimage acting strange when invoked from script ffaker Linux - Software 1 08-19-2005 10:55 AM
Php4 acting strange Sevoma Linux - Software 13 02-15-2005 06:44 PM
Avidemux2 acting strange alitrix Linux - Software 0 12-15-2004 11:55 AM
vim acting strange littlemidget Debian 6 09-17-2004 12:52 PM
suse 9.1 acting strange ozzytx Linux - General 1 08-29-2004 10:41 PM

All times are GMT -5. The time now is 01:21 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration