I noticed that on my Network I have thousands of useless services and I want to remove them, but I want to remove only these starting with "SAMSUNG".
When I run:
% networksetup -listallnetworkservices
I get:
SAMSUNG Modem 1
...
SAMSUNG Modem 1392
Wi-Fi
LGE Android Phone 2
iPhone
Bluetooth PAN
Thunderbolt Bridge
As you can see I have more than on thousand of services starting with "SAMSUNG" and I want to remove only them.
When I trey to remove one of them:
% networksetup -removenetworkservice "SAMSUNG Modem 4"
I just can't because of this error:
You cannot remove SAMSUNG Modem 4 because there aren't any other network services on SAMSUNG Modem.
** Error: The parameters were not valid.
How can I remove this?
I had this problem recently and the solution is very simple
this file contains all network adapters /Library/Preferences/SystemConfiguration/preferences.plist
this command list all samsung modems: networksetup -listallnetworkservices | grep "SAMSUNG Modem"
this command remove one samsung modem (where X is a modem number, ex: "SAMSUNG Modem 155"): networksetup -deletepppoeservice "SAMSUNG Modem X"
To remove all Samsung Modems do it on terminal:
for service in $(/usr/sbin/networksetup -listallnetworkservices | grep "SAMSUNG Modem" ); do
/usr/sbin/networksetup -deletepppoeservice "${service}"
done
Solved by executing the following bash script:
/usr/sbin/networksetup -listallnetworkservices | grep "SAMSUNG Modem" | while read -r line
do
/usr/sbin/networksetup -deletepppoeservice "${line}"
printf 'Deleted %s\n' "${line}"
done
Decided not to touch /Library/Preferences/SystemConfiguration/preferences.plist, not sure if the connection should not be deleted elsewhere.
wish there was a more easy way...but nothing...
i stumbled upon your same issue...
Anyway...you can solve this issue cleaning this file
/Library/Preferences/SystemConfiguration/preferences.plist
And by cleaning i mean: "remove the networkservice you don't need"
UPDATE
I just emptied that file (ofc i did a backup before), opened network in setting and was totally empty (ofc). so i just added a new Position and named "Automatic" and now all works like a charm without the thousand of network bogus services
Have a good day
Antonio
Related
I have written a bash script which starts a tcpip port and connects my device to my laptop for wireless debugging. This is the script at /bin/device_added.sh:
#!/bin/bash
adb shell ip -f inet addr show 2> /tmp/scripts.log
ip=$(adb shell ip -f inet addr show | egrep -o '192.*/' | sed 's/.$//')
adb tcpip 5555
adb connect $ip:5555
echo "USB device added at $(date)" >>/tmp/scripts.log
After configuring permissions with chmod, this works flawlessly on its own. But I want this script to be triggered whenever I plug in usb. I followed this answer to try to make this work. I created a 80-test.rules file at /etc/udev/rules.d and added this:
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="/bin/device_added.sh"
and reloaded the rules file using: sudo udevadm control --reload
Whenever I plug in usb, the script gets run(the date gets logged in scripts.log) but my device doesn't get connected. What am I doing wrong? Why does the script work properly when I run it manually but not when it is triggered through udev?
Edit: On basis of #markp-fuso's and #Charles Duffy's comment, I tried logging the error to /tmp/scripts.log file. Turns out I am getting this error:
line 3: adb: command not found
Now the strange part is, I got this error earlier but I solved it by placing the shell command before the tcpip command(atleast that worked when I ran the script directly). How am I supposed to deal with this error now?
Update:
As #markp-fuso pointed out, the problem was that environment variables weren't accessible to that script. Hence I created a the adb's location as a variable in the script and then made that used that variable as throught. My script now:
#!/bin/bash
adb=/home/pranil/Android/Sdk/platform-tools/adb
$adb shell ip -f inet addr show 2> /tmp/scripts.log
ip=$($adb shell ip -f inet addr show | egrep -o '192.*/' | sed 's/.$//')
$adb tcpip 5555
$adb connect $ip:5555
echo "USB device added at $(date)" >>/tmp/scripts.log
This solved the error I was getting in logs but still the adb doesn't get connected at the required port. I have no idea where I am going wrong now. One more thing, after my script runs, the offline emulator is no longer shown as an output of abd devices command.
I have a sensor device connected to my Ubuntu 20 machine using a serial to usb cable. I understand that to stream data from it I need to run the following commands:
Enter root with sudo -I.
Setup a virtual COM port with stty -F /dev/ttyACM0 9600 cs8 -cstopb -parenb.
Send a command to the device to initiate data streaming with echo -e "some_string" > /dev/ttyACM0.
Stream data with cat < /dev/ttyACM0.
However, I cannot be sure that my device is connected as /dev/ttyACM0. How can I set this up? Currently it has the path /dev/bus/usb/001/005, although the last number changes every time the device is plugged in.
In response to the comment below, here is the output I get when I disconnect the device and run dmesg | tail (I've edited some real values):
[89092.291151] usb 1-1: USB disconnect, device number 11
[89100.310893] usb 1-1: new full-speed USB device number 12 using xhci_hcd
[89100.467562] usb 1-1: New USB device found, idVendor=SOME_ID, idProduct=SOME_PRODUCT, bcdDevice=SOME_BCD_DEVICE
[89100.467565] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[89100.467567] usb 1-1: Product: SOME_PRODUCT
[89100.467569] usb 1-1: Manufacturer: SOME_MANUFACTURER
EDIT: I have just found that I can use sudo modprobe usbserial vendor=SOME_ID product=SOME_PRODUCT to make ttyUSB0 available. However, plugging this into the above commands and running screen /dev/ttyUSB0 only returns lots of ``` characters. Note that this stops when the device is unplugged.
I managed to get this working. The commands were:
sudo -i
rmmod ftdi_sio
rmmod usbserial
modprobe ftdi-sio
echo -n VENDOR_ID PRODUCT_ID | sudo tee /sys/bus/usb-serial/drivers/ftdi_sio/new_id
stty -F /dev/ttyUSB0 9600 cs8 -cstopb -parenb
echo -e "uud1\r" > /dev/ttyUSB0
screen /dev/ttyUSB0 9600
The question pretty much says it all. I basically want to create a driver that is compatible with my current MacOS (Catalina). The issue I'm facing is that my printer (with scanner) currently will only scan pages and print them out. I'd like to be able to use my scanner to save an image of a scanned document.
I'm honestly not sure if writing a driver is the best way to do this but the manufacturer (Canon) no longer has drivers for this old scanner. But it works just as well as the day we got it so I REALLY don't want to have to toss this one out and buy a new one.
UPDATE: currently stuck with the following:
rabdelazin#rabdelazim Downloads % device=$(sane-find-scanner | awk '/Canon/{print $NF}')
rabdelazin#rabdelazim Downloads % echo $device
libusb:020:029
rabdelazin#rabdelazim Downloads % scanimage --device Canon:$device -x 210 -y 297 --mode color --resolution 240 --format=tiff --depth 8 > ~/Downloads/scan.tiff
scanimage: open of device Canon:libusb:020:029 failed: Operation not supported
I have an EPSON Perfection 4990 Photo on macOS, so I cannot give you full code and examples for your Canon but it may get you started. I spend my life in Terminal rather than using GUIs for anything so I just scan the full area of the platten at full resolution and do whatever I need later with ImageMagick or Photoshop if necessary.
So, to get it going I installed homebrew from here. Then I installed some packages:
brew install libusb
brew install sane-backends
Then I can find my scanner with:
sane-find-scanner
Sample Output
found USB scanner (vendor=0x04b8 [EPSON], product=0x012a [EPSON Scanner]) at libusb:003:002
Now you need the last word on that line, the libusb:003:002 part, with my EPSON, I use:
sane-find-scanner | awk '/EPSON/{print $NF}'
You will need to see what you get, and adapt slightly.
SampleOutput
libusb:003:002
So, in order to scan, I capture that in a bash variable called device and do this:
device=$(sane-find-scanner | awk '/EPSON/{print $NF}')
scanimage --device epson:$device -x 210 -y 297 --mode color --resolution 240 --format=tiff --depth 8 > ~/Desktop/scan.tif
I put the whole lot in a bash script called scan like this:
#/bin/bash
TMP="$HOME/Desktop/scan.tif"
# Find libusb device name
device=$(sane-find-scanner | awk '/EPSON|HP/{print $NF}')
if [ -z $device ]; then
echo ERROR: Unable to find libusb device
exit 1
fi
echo Found scanner at: $device
# Now scan full-size, colour, hi res
scanimage --device epson:$device -x 210 -y 297 --mode color --resolution 240 --format=tiff --depth 8 > "$TMP"
# Check we got a file
if [ ! -s "$TMP" ]; then
echo ERROR: Empty scan
exit 1
fi
My script has some further, optional, ImageMagick stuff at the end to create a Web-usable JPEG, if you add this you will need to do:
brew install imagemagick
Then add this to the script above:
# Copy the file to User's Desktop and number nicely...
# ... save as hi-res 16-bit TIF
# ... and medium res, medium quality JPG for web use
cd ~/Desktop
i=0
while :; do
base=$(printf "scan-%03d" $i)
if [ ! -f "${base}.jpg" ]; then
cp "$TMP" "${base}.tif"
convert "$TMP" -resize 2000x2000 -quality 85% "${base}.jpg"
break
fi
((i++))
done
Here are a couple of resources I found helpful when working it all out. You can debug the scanimage program with:
SANE_DEBUG_SNAPSCAN=128 scanimage -L
This resource was useful.
You can get help like this:
scanimage --help -d epson
Note that you may also be able to use a Raspberry Pi or similar small, low-cost Linux machine as a "scanner server". Basically you would attach your scanner via USB to the Raspberry Pi and run SANE on the Raspberry Pi. Once you get it working, you could run saned which is a daemon service, on the Raspberry Pi, that listens on the network for other devices (such as your Mac) making requests to scan. It does the scan, using its Linux SANE drivers and delivers the image back over the Ethernet to the Mac (or other) client. I know you dislike this option, but there may be future readers...
Keywords: macOS, OSX, scan, scanner, scanning, EPSON, Canon, HP, libusb, SANE, sane-backends
Well after a LOT of trial and error, I've finally come up with a solution.
TL;DR: I made a print server out of a raspberry-pi and installed cups and set the printer to be shared through the server. Works like a charm!
It took quite a bit of investigation but as part of reviving an old laptop, I got it running by installing Ubuntu 20.04. Just for kicks I decided to try and print something from the laptop. I had to install CUPS and maybe a few other packages but it worked. That got me thinking that I should just make a print server that knows how to talk to the printer so all the other machines can come and go but my printer should still work.
When i connect my phone to my system and when i enter "adb devices" it shows
"List of devices attached
09478d300f4133f6 device"
Is there a shell command to extract only the name of device? I just want "09478d300f4133f6".
As i am not a programmer i am not expecting any code. Great if the solution can be provided with any shell commands.
You will need to use Linux or Mac OS to run this:
adb devices | grep -w "device" | awk '{print $1;}'
I have USB debugging on and I am showing that the Target is connected I however am unable to connect the host.
When I run the below command on my PC I get output indicating that the command is not complete.
adb forward tcp:4444 localabstract:/adb-hub; adb connect localhost:4444
Output:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Android Studio>adb forward
tcp: 4444 localabstract:/adb-hub;adb connect localhost:4444
Android Debug Bridge version 1.0.31
-a - directs adb to listen on all interfaces for a c
onnection
-d - directs command to the only connected USB devic
e
returns an error if more than one USB device is
present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is r
unning.
-s <specific device> - directs command to the device or emulator with
the given
serial number or qualifier. Overrides ANDROID_S
ERIAL
environment variable.
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
-H - Name of adb server host (default: localhost)
-P - Port of adb server (default: 5037)
devices [-l] - list all connected devices
('-l' will also list device qualifiers)
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number
is specified.
disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.
Port 5555 is used by default if no port number
is specified.
Using this command with no additional arguments
will disconnect from all connected TCP/IP devic
es.
device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> [<local>] - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward --list - list all forward socket connections.
the format is a list of lines with the followin
g format:
<serial> " " <local> " " <remote> "\n"
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb forward --no-rebind <local> <remote>
- same as 'adb forward <local> <remote>' but fail
s
if <local> is already forwarded
adb forward --remove <local> - remove a specific forward socket connection
adb forward --remove-all - remove all forward socket connections
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-s] [--algo <algorithm name> --key <hex-encoded key> --
iv <hex-encoded iv>] <file>
- push this package file to the device and instal
l it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data
)
('-s' means install on SD card instead of inter
nal storage)
('--algo', '--key', and '--iv' mean the file is
encrypted already)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories
)
adb bugreport - return all information from the device
that should be included in a bug report.
adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all]
[-system|-nosystem] [<packages...>]
- write an archive of the device's data to <file>
.
If no -f option is supplied then the data is wr
itten
to "backup.ab" in the current directory.
(-apk|-noapk enable/disable backup of the .apks
themselves
in the archive; the default is noapk.)
(-obb|-noobb enable/disable backup of any insta
lled apk expansion
(aka .obb) files associated with each applic
ation; the default
is noobb.)
(-shared|-noshared enable/disable backup of the
device's
shared storage / SD card contents; the defau
lt is noshared.)
(-all means to back up all installed applicatio
ns)
(-system|-nosystem toggles whether -all automat
ically includes
system applications; the default is to inclu
de system apps)
(<packages...> is the list of applications to b
e backed up. If
the -all or -shared flags are passed, then t
he package
list is optional. Applications explicitly g
iven on the
command line will be included even if -nosys
tem would
ordinarily cause them to be omitted.)
adb restore <file> - restore device contents from the <file> backup
archive
adb help - show this help message
adb version - show version num
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb get-devpath - prints: <device-path>
adb status-window - continuously print device status for a specifie
d device
adb remount - remounts the /system partition on the device re
ad-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the boo
tloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on th
e specified port
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be u
pdated.
- If it is "system" or "data", only the corresponding partition
is updated.
environmental variables:
ADB_TRACE - Print debug information. A comma separated list
of the following values
1 or all, adb, sockets, packets, rwx, usb, sync
, sysdeps, transport, jdwp
ANDROID_SERIAL - The serial number to connect to. -s takes prior
ity over this if given.
ANDROID_LOG_TAGS - When used with the logcat option, only these de
bug tags are printed.
For your information, I finally solved the same problem by replacing port 4444 by 5601.
The 2 calls are:
adb forward tcp:5601 localabstract:/adb-hub
and
adb connect localhost:5601
(My Android Wear device is a LG G Watch and my Android tablet is an Asus Nexus 7)
This is easy to solve:
I had the same problem.
Just devide this into two calls.
First enter:
adb forward tcp:4444 localabstract:/adb-hub
hit Enter and after that:
adb connect localhost:4444
Enter and it should connect. If not try first to start the "adb start-server"
try Ip address instead of localhost when connecting
adb forward tcp:4444 localabstract:/adb-hub
adb connect 127.0.0.1:4444
I had this problem as well. After running the above commands in the Command Line, I solved it by activating the Developer Options on my Moto 360 (pressing the build number repeatedly in the settings like the phone). Enabling the ADB and Bluetooth Debugging on the watch and unpairing my watch with my phone.
After I did all these steps my computer finally sent the RSA permissions key for my Android Wear device through my phone.
The Complete solution for this issue..
1. Open Your-sdk-path in Explorer.
2. Open platform-tools.
3. Shift + Rightclick then select Open command window here.
4. adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444 (For Real Device).
5. adb -d forward tcp:5601 tcp:5601 (for EMulator).
Then after connect with emulator in Android wear companion app.
Before Doing step 4 please ensure that debugging over bluetooth is enabled in developer option.
Open Your-sdk-path in Explorer, and then "platform-tools", where it should be your adb.exe , in my case this is ( C:\Users\YourUser\AppData\Local\Android\sdk\platform-tools )
Shift + Rightclick then select Open command window here.
paste "adb forward tcp:4444 localabstract:/adb-hub"
And then paste "adb connect 127.0.0.1:4444" (do not put localhost it is giving problems).
you can check with "adb devices"
I also had issue adb debugging over bluethooth:
Debugging over Bluetooth was always Off for me. Apparently I had to choose a debugging wearable device here:
Android Wear -> Settings (gear icon) -> Debugging over Bluetooth -> Device to Debug
Then all other comments are helpful too.
Tried all of the above, nothing helped.
The one thing that helped me was to restart the phone...