在 bash 脚本中启动程序并执行命令

Ves*_*nog 2 bash shell-script

如何在 root 中执行我在 bash 脚本中启动的命令?我的目标是让 ROOT 执行其 GUI 文件浏览器,并在用户不干扰键盘命令的情况下将其打开。我尝试过但失败了,因为 GUI 文件浏览器在很短的时间内保持打开状态。是否可以修改 bash 脚本并在脚本终止时打开程序?

ROOT 的说明可以在以下链接中找到:

http://root.cern.ch/drupal/

Nid*_*dal 5

只需输入命令,它将被执行:

#!/bin/bash
ls -l
Run Code Online (Sandbox Code Playgroud)

如果要运行其他 shell 脚本,请使用:

sh otherShell.sh
Run Code Online (Sandbox Code Playgroud)

或者对于可执行文件:

. otherShell.sh
Run Code Online (Sandbox Code Playgroud)

gnuplot 和其他命令一样,你可以在 shell 脚本中使用它:

例子:

#!/bin/sh
lib=$1
old="output/old/$lib.dat"
new="output/new/$lib.dat"

gnuplot << EOF
set logscale x
set logscale y
set size square
set grid
set pointsize 1
plot "< paste $old $new" using 1:4 ti '$lib'
EOF
Run Code Online (Sandbox Code Playgroud)

对于“它没有时间查看和与应用程序中启动的 GUI 交互”的问题:您可以告诉 gnuplot 将绘图打印到文件,您可以打开并查看自己:

plot '<SOME FILE>' .......
Run Code Online (Sandbox Code Playgroud)

或者您需要使用标志调用 gnuplot:

gnuplot --persist
Run Code Online (Sandbox Code Playgroud)

确保在 gnuplot 退出后绘图保持不变。

资料来源:

使用 bash 自动绘制 gnuplot

http://www.unix.com/shell-programming-and-scripting/146860-using-variables-gnuplot-within-shell-script.html