Share your knowledge at the LQ Wiki.
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, 10: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, 10:29 AM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
It sounds like the problem is above the grep code.
stdout/stderr is being redefined or doesn't exist.
Old 12-14-2004, 11:15 AM   #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 09:55 AM
Php4 acting strange Sevoma Linux - Software 13 02-15-2005 05:44 PM
Avidemux2 acting strange alitrix Linux - Software 0 12-15-2004 10:55 AM
vim acting strange littlemidget Debian 6 09-17-2004 11:52 AM
suse 9.1 acting strange ozzytx Linux - General 1 08-29-2004 09:41 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:20 PM.

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