The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



"bash скрипт для монтирования андроид телефона"
Версия для распечатки Пред. тема | След. тема
Форум Открытые системы на рабочей станции
Исходное сообщение [ Отслеживать ]

. "bash скрипт для монтирования андроид телефона" +/
Сообщение от Isothiocyanate (ok), 12-Янв-21, 20:51 
#!/bin/bash
echo "This script will mount yors Android phone using go-mtpfs."
echo " Firstly install go-mtpfs, MTP protocol, then make dir called AndroidDevice in yours /home/user_name catalog."
echo " Make dir AndroidDevice in yours home catalog? Yes=1 No=2"
read D
if [[ "D" = "1" ]]  
then
mkdir ~/AndroidDevice
echo "mount point is created."
else
go-mtpfs ~/AndroidDevice &
# Note: If go-mtpfs is not ran in the background (with & at the end), another console will be needed to browse the device and unmount the device (when finished).
echo "Device is mounted."
fi
echo "Do you wish unmount it? Yes=press any key"
read B
fusermount -u ~/AndroidDevice
echo " Unmount is Ok."
#When the device is unmount, go-mtpfs will quit.

Теперь работает как надо.
rost@DEBIAN999:~/Mount_Android_Phone$ ./Android_mount_script2
This script will mount yors Android phone using go-mtpfs.
Firstly install go-mtpfs, MTP protocol, then make dir called AndroidDevice in yours /home/user_name catalog.
Make dir AndroidDevice in yours home catalog? Yes=1 No=2
2
Device is mounted.
Do you wish unmount it? Yes=press any key
2021/01/12 19:47:27 FUSE mounted
l
Unmount is Ok.
rost@DEBIAN999:~/Mount_Android_Phone$

Позже я попробую сделать автомтическую проверку на наличие директории монтирования и создании таковой если ее нет.

Хотя нет, мне же надо сравнить числа а не строки:

#!/bin/bash
echo "This script will mount yors Android phone using go-mtpfs."
echo " Firstly install go-mtpfs, MTP protocol, then make dir called AndroidDevice in yours /home/user_name catalog."
echo " Make dir AndroidDevice in yours home catalog? Yes=1 No=2"
read D
if [[ "$D" -eq 1 ]]  
then
mkdir ~/AndroidDevice
echo "mount point is created."
else
go-mtpfs ~/AndroidDevice &
# Note: If go-mtpfs is not ran in the background (with & at the end), another console will be needed to browse the device and unmount the device (when finished).
echo "Device is mounted."
fi
echo "Do you wish unmount it? Yes=press any key"
read B
fusermount -u ~/AndroidDevice
echo " Unmount is Ok."
#When the device is unmount, go-mtpfs will quit.

Выхлоп:
rost@DEBIAN999:~/Mount_Android_Phone$ ./Android_mount_script2
This script will mount yors Android phone using go-mtpfs.
Firstly install go-mtpfs, MTP protocol, then make dir called AndroidDevice in yours /home/user_name catalog.
Make dir AndroidDevice in yours home catalog? Yes=1 No=2
2
Device is mounted.
Do you wish unmount it? Yes=press any key
2021/01/12 19:55:18 FUSE mounted
f
Unmount is Ok.
rost@DEBIAN999:~/Mount_Android_Phone$ ./Android_mount_script2
This script will mount yors Android phone using go-mtpfs.
Firstly install go-mtpfs, MTP protocol, then make dir called AndroidDevice in yours /home/user_name catalog.
Make dir AndroidDevice in yours home catalog? Yes=1 No=2
1
mkdir: cannot create directory ‘/home/rost/AndroidDevice’: File exists
mount point is created.
Do you wish unmount it? Yes=press any key
e
fusermount: entry for /home/rost/AndroidDevice not found in /etc/mtab
Unmount is Ok.
rost@DEBIAN999:~/Mount_Android_Phone$

Ответить | Правка | Наверх | Cообщить модератору

Оглавление
bash скрипт для монтирования андроид телефона, Isothiocyanate, 11-Янв-21, 18:53  [смотреть все]
Форумы | Темы | Пред. тема | След. тема



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру