Comments (10)
hello @tnguyen14, try to use printf
instead echo
list_netservices(){
networksetup -listallhardwareports | while IFS= read -r line; do
# if it is a device we will print the ip in the next line
if echo ${line} | grep -i "Device" >/dev/null 2>&1; then
#echo "${line}\nIp: $(ipconfig getifaddr $(echo ${line} | cut -d: -f2 2>/dev/null))"
printf "${line}\nIP:$(ipconfig getifaddr $(echo ${line} | cut -d: -f2 2>/dev/null))\n"
else
#echo ${line}
printf "${line}\n"
fi
done
}
I'll update the function soon to avoid this error.
from m-cli.
Hello @REBELinBLUE I've changed this to use printf
instead echo
in the latest version (v0.1.8), it should work now
from m-cli.
ifconfig
does that, I suppose you want the same functionality but more readeable like the output of m network ls
, am I right?
Feel free to create a pull request with your enhancements 👍 😃
from m-cli.
Yeah, I'm good friends with ifconfig
, but it's way too verbose. The output from m
is quite readable, and I'd love to see more things like IP addresses in it.
I'll take a whack at the code (not necessarily tonight) and see what I can do.
from m-cli.
So I did just take a quick look at the code, and it's written in the Bourne Shell. I checked into associative arrays in bash, and they're only support in Bash version 4.
Do we have the option of contributing code in a language other than shell? If so, I'll proceed. (I'm thinking PHP, but more than happy to do Python...)
from m-cli.
Hello @dmuth I think we need to keep it as simple as possible, so I wrote a simple shell function to do it
This is an example of the output:
Hardware Port: Wi-Fi
Device: en0
Ip: 192.168.1.1
Ethernet Address: AA:BB:CC:DD:EE:FF
Hardware Port: Bluethoot PAN
Device: en4
Ip:
Ethernet Address: AA:BB:CC:DD:EE:FF
from m-cli.
I just looked at your solution code, and wasn't aware of the ipconfig
command. Had I know that, I would have used it. Nice job!
from m-cli.
@rgcr I just tried using your solution
list_netservices(){
networksetup -listallhardwareports | while IFS= read -r line; do
# if it is a device we will print the ip in the next line
if echo ${line} | grep -i "Device" >/dev/null 2>&1; then
echo "${line}\nIp: $(ipconfig getifaddr $(echo ${line} | cut -d: -f2 2>/dev/null))"
else
echo ${line}
fi
done
}
I'm seeing this in the output
:; list_netservices
Hardware Port: Wi-Fi
Device: en0\nIp: 10.200.13.17
Ethernet Address: 78:31:c1:d0:3f:20
Hardware Port: Bluetooth PAN
Device: en4\nIp:
Ethernet Address: 78:31:c1:d0:3f:21
Hardware Port: Thunderbolt 1
Device: en1\nIp:
Ethernet Address: 72:00:02:b4:7b:20
I'm guessing the \n
is not formatted correctly?
from m-cli.
@rgcr that works great. thanks!
from m-cli.
In the latest version I am not getting the newline, rather the escape character
Hardware Port: Targus USB3 DV1K-2K Compact Doc
Device: en7\nIp: 10.152.29.116
Ethernet Address: 00:50:b6:cc:46:23
from m-cli.
Related Issues (20)
- Firewall State 2 HOT 6
- Automated test suite
- Airdrop status outputs an error first use HOT 1
- `m trash status` return incorrect content info
- wallpaper command only sets wallpaper for current desktop HOT 2
- set wallpaper to hex color instead of image file HOT 4
- localhost operator uses wrong sed parameter HOT 2
- Fix hard coded default wi-fi interface HOT 2
- We can add more features to DNS plugin HOT 1
- Bash 5.1 errors, unary operator expected HOT 2
- Usage information not following POSIX standard HOT 2
- Headless HOT 1
- Combined itunes play/pause
- AirDrop off disables airdrop even after uninstall
- Roadmap HOT 1
- m bluetooth is not working in apple m1 pro
- m bluetooth is not working in apple m1 pro HOT 2
- Looking for maintainers HOT 2
- Provide option to change default app
- VPN connects to a wrong one
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from m-cli.