我是这个平台的新手。我有关于rc.local 的问题。我创建了一个脚本来自动运行roscore和roslaunch rosbridge_server rosbridge_websocket.launch。此脚本名称为auto,脚本内容为:
#!/bin/sh
cd $home
xterm -hold -e "roscore" &
xterm -hold -e "roslaunch rosbridge_server rosbridge_websocket.launch"
exit 0
Run Code Online (Sandbox Code Playgroud)
我必须在 rc.local 中运行这个脚本。创建的 rc.local 文件是:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just …Run Code Online (Sandbox Code Playgroud) 如果存在某个文件,我只想检查 bash。
在此页面上提到了两个选项可用于if:
[ -a FILE ] - 如果文件存在则为真[ -e FILE ] - 如果文件存在则为真它们是等效的还是它们之间有什么区别?
我的问题与这个问题相同,但我无法在 ubuntu 17.10 中使用它:
我想运行一个脚本,在屏幕锁定时更改我的键盘 RGB 配置。脚本运行完美。问题是获取锁定/解锁的事件。我已尝试使用 dbus-monitor ,如该问题所述和此处所述:
https://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html
所以运行这个脚本:
#!/bin/bash
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | \
( while true
do read X
if echo $X | grep "boolean true" &> /dev/null; then
echo "locking at $(date)" >> $HOME/time_xprofile
elif echo $X | grep "boolean false" &> /dev/null; then
echo "unlocking at $(date)" >> $HOME/time_xprofile
fi
done )
Run Code Online (Sandbox Code Playgroud)
但它只能工作......几次(!)......我无法理解会发生什么。
我在 X-server 上使用 ubuntu 17.10 和 ubuntu 的 gnome(没有 Wayland),并尝试过 vanilla gnome 并遇到同样的问题。
我也试过:
dbus-monitor > out.log
Run Code Online (Sandbox Code Playgroud)
要查看锁定/解锁时出现的所有痕迹,但没有出现该信号......只有......好吧......很少......
我不知道该怎么做,任何建议都会有所帮助。
YAD是 Zenity 分叉。
我有这个yad脚本:
#!/bin/bash
yad --text="Execute the file? (press 'Cancel' to open in text editor)"
case $? in
0)thunar "$1"
;;
1)gedit $1
;;
esac
Run Code Online (Sandbox Code Playgroud)
与作为应用程序启动器的桌面文件相关联,它可用于在单击文件(例如脚本等)时显示一个窗口。
在 zenity 中,可以编辑标签的名称:
Zenity 的相同脚本应如下所示:
#!/bin/bash
zenity --question --text="What to do?" \
--ok-label=Run \
--cancel-label=Edit
case $? in
0)thunar "$1"
;;
1)gedit $1
;;
esac
Run Code Online (Sandbox Code Playgroud)
而Run与Edit可以改变的。
我认为这里说的是yad编辑标签的方法:
--button=Button:ID
Run Code Online (Sandbox Code Playgroud)Add the dialog button. May be used multiply times. ID is an exit code …
如何创建一个接收向量参数的 shell 脚本,如
./script.sh google.com,yahoo.com
并显示每个域的 ip
像 google.com 100.23.123.13
编辑:
#!/bin/bash
while [ "$1" ];
do
host $1 | grep address | head -1
done
Run Code Online (Sandbox Code Playgroud) 如何将命令行参数传递给 atd 守护进程,该参数将在重新启动和软件包升级后持续存在?我希望向-l 7.5atd添加命令行标志,因为我有一个 8-CPU 服务器并且不想在运行批处理作业之前等待负载级别低于编译值 1.5。
(这里已经回答了一个类似的问题,但该答案对 Ubuntu 16.04 无效,因为文件 /etc/init.d/atd.conf 不存在,并且我的 /etc/init 中没有“exec atd”行.d/atd 文件。)
与 /etc/init.d/ 中的大多数脚本不同,/etc/defaults/ 中没有相应的 atd 文件,因此我无法在其中进行任何编辑。
这是 /etc/init.d/atd 脚本:
#! /bin/sh
### BEGIN INIT INFO
# Provides: atd
# Required-Start: $syslog $time $remote_fs
# Required-Stop: $syslog $time $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Deferred execution scheduler
# Description: Debian init script for the atd deferred executions
# scheduler
### …Run Code Online (Sandbox Code Playgroud) 当我运行py脚本时出现这样的错误
RuntimeError: To use MKL 2018 with Theano you MUST set "MKL_THREADING_LAYER=GNU"
in your environement.
Run Code Online (Sandbox Code Playgroud)
我用谷歌搜索原因并在终端尝试
export MKL_THREADING_LAYER=GNU
Run Code Online (Sandbox Code Playgroud)
并再次运行,但问题仍然存在。我想检查环境变量是否存在,所以我试过了
$ env MKL_THREADING_LAYER=GNU
env: ‘MKL_THREADING_LAYER’: No such file or directory
Run Code Online (Sandbox Code Playgroud)
这是否意味着我没有得到环境或什么?
回到原来bug的代码,问题是这样的:
File "/home/chen/anaconda2/envs/rllab3/lib/python3.5/site-packages/theano/configdefaults.py", line 1251, in check_mkl_openmp
Run Code Online (Sandbox Code Playgroud)
库的代码是这样设计的:
RuntimeError: To use MKL 2018 with Theano you MUST set "MKL_THREADING_LAYER=GNU"
in your environement.
Run Code Online (Sandbox Code Playgroud)
如何设置此环境变量并使原始代码工作?
我想git clone使用
git clone https://github.com/someRepository > git_clone.file
Run Code Online (Sandbox Code Playgroud)
但相反,我在终端中显示/更新了输出,例如
Cloning to 'someRepository' ...
remote: Counting objects: 2618, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 2618 (delta 2), reused 12 (delta 1), pack-reused 2603
Received objects: 100% (2618/2618), 258.95 MiB | 4.39 MiB/s, Done.
Resolving Differences auf: 100% (1058/1058), Done.
Check Connectivity ... Done.
Run Code Online (Sandbox Code Playgroud)
但文件git_clone.file已生成但仍为空。
我最初的目标是绕过输出git到函数中(请参阅我的问题here)。但是现在我意识到git甚至似乎没有产生stdout真正但不知何故不同的输出,因为没有任何内容写入文件。
如何从中获取此显示的输出git以将其重定向到文件/函数?
编辑
建议的stderr(and stdout)重定向没有解决问题。
git clone https://github.com/someRepository …Run Code Online (Sandbox Code Playgroud) 这个问题与我在这里的旧问题有关。
在我终于找到了如何将 git 的输出绕过到函数中之后,我现在遇到了另一个问题。使用
git clone --progress XYZ &> git_clone.file
Run Code Online (Sandbox Code Playgroud)
按预期写入
Cloning to 'someRepository' ...
remote: Counting objects: 2618, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 2618 (delta 2), reused 12 (delta 1), pack-reused 2603
Received objects: 100% (2618/2618), 258.95 MiB | 4.39 MiB/s, Done.
Resolving Differences auf: 100% (1058/1058), Done.
Check Connectivity ... Done.
Run Code Online (Sandbox Code Playgroud)
进入git_clone.file。
现在我不想将输出重定向到文件而是重定向到函数,所以我使用
function PrintInfo(){
tput el
echo $1
<Print ProgressBar>
#For further details about this see
# https://askubuntu.com/questions/988403/bash-pass-command-output-to-function-in-realtime
} …Run Code Online (Sandbox Code Playgroud) 我在 macbook air 上运行 Linux mint kde。今天我登录并尝试打开Firefox,它无法打开。我做了一些故障排除,我发现我无法修改文件。它说这是一个“只读”文件系统,我需要“联系我的管理员”。我重新启动了系统,它没有再次启动。它转到一个命令行,说BusyBox built-in shell (ash)并initramfs作为用户。
这是我唯一的电脑,我不知道我在做什么,我真的需要它重新启动。请帮忙
我可以在我的机器上安装它们还是有任何问题?
如果可能的话,你能告诉我怎么做吗?