yum -y install phpmyadmin
Run Code Online (Sandbox Code Playgroud)
出现错误:
Error: Package: phpMyAdmin-4.4.15.10-2.el7.noarch (epel)
Requires: php-zip
Available: php-common-5.4.16-42.el7.x86_64 (base)
php-zip
Available: php-common-5.4.16-43.el7_4.x86_64 (updates)
php-zip
Available: php-pecl-zip-1.15.1-2.el7.remi.7.2.x86_64 (remi-php72)
php-zip = 1:1.15.1-2.el7.remi.7.2
Available: php-pecl-zip-1.15.2-1.el7.remi.7.2.x86_64 (remi-php72)
php-zip = 1:1.15.2-1.el7.remi.7.2
Available: php55w-common-5.5.38-1.w7.x86_64 (webtatic)
php-zip
Available: php56w-common-5.6.31-1.w7.x86_64 (webtatic)
php-zip
Available: php56w-common-5.6.31-2.w7.x86_64 (webtatic)
php-zip
Available: php56w-common-5.6.32-1.w7.x86_64 (webtatic)
php-zip
Available: php70w-common-7.0.22-2.w7.x86_64 (webtatic)
php-zip
Available: php70w-common-7.0.23-1.w7.x86_64 (webtatic)
php-zip
Available: php70w-common-7.0.23-2.w7.x86_64 (webtatic)
php-zip
Available: php70w-common-7.0.24-1.w7.x86_64 (webtatic)
php-zip
Available: php70w-common-7.0.25-1.w7.x86_64 (webtatic)
php-zip
Available: php71w-common-7.1.8-2.w7.x86_64 (webtatic)
php-zip
Available: php71w-common-7.1.9-1.w7.x86_64 (webtatic)
php-zip
Available: php71w-common-7.1.9-2.w7.x86_64 (webtatic)
php-zip
Available: …Run Code Online (Sandbox Code Playgroud) 我正在 Mac 上学习 bash:
我的 Mac 中有一个最简单的 bash 脚本,它命名为untitled.sh:
#!/bin/bash
echo "hello"
Run Code Online (Sandbox Code Playgroud)
但是在我的终端中我想运行它,我失败了:
$ sudo ./untitled.sh
Password:
sudo: ./untitled.sh: command not found
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会出现错误,一切正常。
我正在尝试使用 sed 从文件中的一行中提取特定字符串。目前我正在使用 while 循环读取文件并搜索特定字符串。当找到该字符串时,我正在提取它,但是我需要使用 sed 来解析输出,以便我只获取两个斜杠之间的字符串(它是一个目录名,所以如果可能的话,我需要同时保留开头和结尾的斜杠)。这是我正在运行以搜索文件的循环:
#!/bin/sh
file=configFile.conf
while read line
do
if echo "$line" | grep -q "directory_root"
then DIR_ROOT="$line"
fi
done < "$file"
echo $DIR_ROOT
exit 0
Run Code Online (Sandbox Code Playgroud)
while 循环起作用并回显以下字符串:
directory_root /root/config/data/
Run Code Online (Sandbox Code Playgroud)
然后我需要使用 sed 以获得以下输出,以便将正确的目录名称传递给另一个脚本:
/root/
Run Code Online (Sandbox Code Playgroud)
是否可以使用 sed 和正则表达式从回显输出中仅提取上述内容?
谢谢
我目前正在尝试将我的 Android 手机连接到我的 Windows 机器,同时充当 HID、RNDIS 和 MASS_STORAGE 设备。作为单一模式的每个模式都可以正常工作,但我无法将它们正确组合,例如,我可以使用 HID、MASS_STORAGE 但 Norfilter 过滤器 HID、RNDIS。目前的最佳工作实践是通过 shell 设置 USB 模式,例如
setprop sys.usb.config mass_storage,adb
Run Code Online (Sandbox Code Playgroud)
我还致力于使用:
echo 0 > /sys/class/android_usb/android0/enable
echo ecm,adb > /sys/class/android_usb/android0/functions
echo 1 > /sys/class/android_usb/android0/enable
Run Code Online (Sandbox Code Playgroud)
这样我也可以让网络接口 ecm0 运行。
从网上的所有内容来看,我可以使用 sysfs 或 configfs 来设置我自己的具有不同功能的小工具。因此,我必须将 /config 作为配置挂载在我的手机上,但无论我尝试什么,/config 目录都保持为空且只读。
有谁知道在 Android Shell 中设置 USB-Gadget 的正确方法吗?
我想创建一个调用另一个脚本或命令作为包装器的 BASH 脚本。调用参数应该被收集传递,但有一个例外。如何过滤特殊参数名称值对?
例如,当我使用参数 count 调用第一个脚本时X=$#:
$ ./foo.sh -v --first val1 ... --argname 'value with spaces' ... --last val3
Run Code Online (Sandbox Code Playgroud)
然后它应该使用新的参数 count 调用第二个命令或脚本X'=X-2:
$ ./bar.sh -v --first val1 ... --last val3
Run Code Online (Sandbox Code Playgroud) 这个 bash 脚本将一个数组写入一个文件,然后将该文件读回另一个数组。(这对于脚本之间基于数组的通信很有用。)但是,该IFS行(第 12 行)捕获了一个奇怪的、未报告的错误。为什么?
#!/bin/bash
# eso-error-ic
trap 'echo Error trapped, with code $?, on line ${LINENO}' ERR
# write data to a file
arr=(0 abc) && printf "%s\n" "${arr[@]}" > eso.out
# read data from the file into an array
# throws an error!!
IFS=$'\n' read -d '' -a new_arr < eso.out
# but it worked...
echo ${new_arr[0]}
echo ${new_arr[1]}
Run Code Online (Sandbox Code Playgroud)
脚本输出:
Error trapped, with code 1, on line 12
0
abc
Run Code Online (Sandbox Code Playgroud)
缺少的是产生错误时显示的任何类型的消息。你得到的只是来自陷阱的消息,但没有关于错误是什么的消息。 …
我正在尝试更新我的/etc/shells文件以包含bash其所在的自制软件安装版本的路径/usr/local/bin/bash
$ sudo echo /usr/local/bin/bash >> /etc/shells 返回权限被拒绝,不允许尝试手动更新,因为它似乎是只读的。
检查文件后,权限设置如下:
-rw-r--r-- 1 root wheel 179 Feb 21 2017 /etc/shells
因此,考虑到这一点,在阅读了这篇关于使用 Homebrew 更新 shell 的文章后,我尝试以 root 用户身份启动一个 shell,然后尝试上面的命令,即:
$ sudo -s
$ echo /usr/local/bin/bash >> /etc/shells
$ chsh -s /usr/local/bin/bash
Run Code Online (Sandbox Code Playgroud)
但是,这似乎挂在第一个命令 ( $ sudo -s) 上。这会产生一个bash进程,它占用了大约 70% 的 CPU,并且什么也没有发生。
有没有另一种方法可以更新/etc/shells/文件?
我们有大量用于各种用途的 shell 函数集合,这些函数被添加到我们的 .bash_profiles 中,我们每天都在使用。我们将这些函数称为常规二进制文件。
我试图从 Go 应用程序内部调用这些相同的 shell 函数,但它找不到它们,因为它显然在不同的上下文中运行,并且在我的 $PATH 中找不到它们。
错误是:
exec: "finderx": executable file not found in $PATH
有谁知道如何在与运行终端相同的上下文中从 Go 应用程序执行 shell 命令?或者,如果可能的话,我可能不想重新实现这些功能。
我想像我们从脚本中那样称呼它们以缓解过渡期。我们将逐渐将所有内容转移到 Go,但现在,我们必须忍受 shell 函数
I have a python program that has to be running all the time. If for some reason it was stopped I want to restart it automatically. I thought of having a cron that will run every n number of seconds and check the program is running. My shell script is looks like this:
#!/usr/bin/env bash
CM_COMMAND=`ps aux| grep abc| grep def| grep sudo`
LEN_COMMAND=${#CM_COMMAND}
if[["$LEN_COMMAND" -le "5"]]
then
echo "start the python program"
fi
exit
Run Code Online (Sandbox Code Playgroud)
When I run this script …
这种方法有什么问题我无法获得正确的数组长度值
#!/bin/bash
foo(){
val=$@
len=${#val[@]}
echo "Array contains: " $val
echo "Array length is: " $len
}
var=(1 2 3)
foo ${var[@]}
Run Code Online (Sandbox Code Playgroud)
输出:
Array contains: 1 2 3
Array length is: 1
Run Code Online (Sandbox Code Playgroud)