Check whether iPhone device connected with system from commandline? - iphone

One of my requirement is "whether iPhone/iPad connected with system from command line" in my currently developing component. or any other systematic way rather than manual?
Expecting your favorable reply soon. thanks in advance...
sri

On a Mac:
ioreg -w -p IOUSB | grep -w iPad
ioreg -w -p IOUSB | grep -w iPhone
I don't know how an iPod Touch shows up.

Related

HDMI-CEC - control brightness

is there any way to control TV brightness over HDMI CEC?
I built the TV into a frame and forgot to turn down the brightness...Any chance or would I have to unframe it in order to be able to use the remote?
Commands like echo 'volup' | cec-client -s -d 1 work fine, but is there any way to control the brightness? Maybe by transfering specific bytes?
Thanks in advance!
Have you tried:
echo h | cec-client -s -d 1
Source: https://raspberrypi.stackexchange.com/a/9147

Play online Radio Station as a Music on Hold in Asterisk

Is there a way (Tool or any idea) to play radio station (Streamed via IceCast) as a Music On Hold in Asterisk?, I Have a streaming server and Asterisk Server running and working independently very well, only I want to integrate both of two.
Your Help Please, THANKS IN ADVANCE
My OS: Linux - Centos
My Music On Hold Class:
mode=custom
application=/usr/bin/sox mystreamingurl -b 64000 -r 44100 -t ogg -
This script produces upnormal and noisy sound which is totally different from the sound produced by the Streaming Server(IceCas).
Used MPG123 player and worked like a charm
Udated MOH Class:
mode=custom
application=/usr/bin/mpg123 -q -r 8000 -f 8192 --mono -s http://mystreamingurl
Asterisk's internal sound format is 8khz mono PCM
You should directly specify for sox which output format to use for in and out.
Also sox is NOT streaming utility, you should use something like MPlayer.
https://www.voip-info.org/asterisk-config-musiconholdconf/#StreamradiousingMPlayerforMOH
#!/bin/bash
if -n "`ls /tmp/asterisk-moh-pipe.*`" ; then
rm /tmp/asterisk-moh-pipe.*
fi
PIPE="/tmp/asterisk-moh-pipe.$$"
mknod $PIPE p
mplayer http://address_of_radio_station -really-quiet -quiet -ao pcm:file=$PIPE -af resample=8000,channels=1,format=mulaw 2>/dev/null | cat $PIPE 2>/dev/null
rm $PIPE

Determine if app is Wayland or X client

Is there a way to determine if an arbitrary app is an X client or a Wayland client (or neither) from the command line without fully launching it?
You can run ldd on the binary to check which libraries it links against. If it has "libwayland-client" you're probably looking at a Wayland client. For X you need to look for "libX11" or "libxcb".
To expand on the excellent answer given by #Alexander Sukhoverkhov what needs to be done is:
cd /usr/bin
ldd $application_name | grep wayland
Furthermore, to check which binaries have wayland support you could try:
cd /usr/bin
find . | xargs ldd | grep wayland -B 55
The above is not really very clean but it works. You can further pipe it to a file and then use vim to navigate.
cd /usr/bin
find . | xargs ldd | grep wayland -B 55 >> candidates
vim candidates
# Use vi movement
The -B flag stands for before and helps to print the binary name.

Bash: how to make a substitution in a "live" pipe?

In my office firewall I use a command like this:
$ sudo tcpdump -v -s 1500 -i eth0 port 25 | grep 'smtp: S'
to monitor LAN clients sending mail (I need to early detect any possible spammer bot from some client, we have very looooose security policies, here... :-().
So far, so good: I have a continuous output as soon any client sends an email.
But, if I add some filter to get a cleaner output, something like this:
$ sudo tcpdump -v -s 1500 -i eth0 port 25 | grep 'smtp: S' | perl -pe 's/(.*?\)) (.*?)\.\d+ \>(.*)/$2/'
(here I intend to get only source ip/name), I do not get any output until tcpdump output is more than (bash?) buffer size... (or at least I suppose so...).
Nothing changes using 'sed' instead of 'perl'...
Any hint to get a continuous output of filtered data?
Put stdbuf before the first command:
sudo stdbuf -o0 tcpdump ...
But, if I add some filter to get a cleaner output, something like
this:
Use the --line-buffered option for grep:
--line-buffered
Use line buffering on output. This can cause a performance
penalty.
try maybe a sed --unbuffered (or -u sometimes like on AIX) to have a stram version (not waiting the EOF)

scripting with sed and wget in Windows

I have some issue with Internet connectivity in a LAN. Some users are happy and some complain about the Internet speed. So I came with an idea to install software on three different PCs and try to download/upload a file at the same time and record the speed. Then I will able to create a graph with the data that I acquired.
I am looking for a way to download several files and check the speed. I found How to grep download speed from wget output? for wget and sed. How do I use wget -O /dev/null http://example.com/index.html 2>&1 | sed -e 's|^.*(\([0-9.]\+ [KM]B/s\)).*$|\1|' for Windows? I already installed wget and sed on Windows.
All PCs running Windows XP or 7.
Sed isn't different on Windows. The only difference is, that /dev/null doesn't exist on Windows, but NUL.
So:
wget -O NUL http://example.com/index.html 2>&1 | sed -e 's|^.*(\([0-9.]\+ [KM]B/s\)).*$|\1|'
should work on Windows. I'm not 100% sure about 2>&1 - maybe there is some other syntax to use.