如果有人想从Bash调用外部程序(它作为Bash参数传递)并传递命令行选项(也作为Bash参数传递),解决方案很简单:
TCL_SCRIPT="$1"
shift
TCL_SCRIPT_ARGUMENTS="$@"
expect -f "$TCL_SCRIPT" "$TCL_SCRIPT_ARGUMENTS" 2>&1
Run Code Online (Sandbox Code Playgroud)
在TCL/Expect中有类似的可能性吗?
编辑:到目前为止,我已经来了这个黑客(评论中有Bash等价物),似乎它正在运作.有人可以解释lshift程序吗?
# http://wiki.tcl.tk/918#pagetocc7993a2b
proc lshift {inputlist} {
upvar $inputlist argv
set arg [lindex $argv 0]
#set argv [lrange $argv 1 end] ;# below is much faster - lreplace can make use of unshared Tcl_Obj to avoid alloc'ing the result
set argv [lreplace $argv[set argv {}] 0 0]
return $arg
}
# BASH: TCL_SCRIPT="$1"
set script [lindex $argv 0]
# BASH: shift
lshift argv
# BASH: TCL_SCRIPT_ARGUMENTS="$@"
set arguments $argv
Run Code Online (Sandbox Code Playgroud) bash arguments expect argument-passing command-line-arguments
我与TCL命令尝试exec在tclsh这里是我的结果:
% set show_me_dir "ls"
ls
% exec $show_me_dir
VboxSharedFolder
% set show_me_dir "ls -la"
ls -la
% exec $show_me_dir
couldn't execute "ls -la": no such file or directory
% set show_me_dir {ls -la}
ls -la
% exec $show_me_dir
couldn't execute "ls -la": no such file or directory
% ls -la
total 141
d---------+ 1 wakatana Domain Users 0 Jan 22 19:12 .
d---------+ 1 wakatana Domain Users 0 Apr 16 2014 ..
----------+ 1 wakatana …Run Code Online (Sandbox Code Playgroud) 我正在尝试进行Windows内核调试,因此我为此设置了两台计算机:
HOST和TARGET都运行Windows 7 32位,并且都安装了Windows Driver Kit 8.0。我做了以下步骤:
在TARGET上,我使用以下命令启用了内核调试:
bcdedit /copy {current} /d "Windows 7 wih debug"
bcdedit /debug {02b760e4-eafc-11e4-8847-ac1155aec81a} on
bcdedit /dbgsettings serial debugport:1 baudrate:115200
bcdedit /set {bootmgr} displaybootmenu yes
bcdedit /timeout 10
Run Code Online (Sandbox Code Playgroud)
然后,我开始启动HOST并执行以下步骤:
之后,我在HOST上的windbg命令窗口如下所示:
Microsoft (R) Windows Debugger Version 6.2.9200.20512 X86
Copyright (c) Microsoft Corporation. All rights reserved.
Opened \\.\COM1
Waiting to reconnect...
Run Code Online (Sandbox Code Playgroud)
然后,我重新启动TARGET并从启动菜单中选择“带有调试功能的Windows 7”。
之后,我在HOST上的windbg命令窗口如下所示:
Microsoft (R) Windows Debugger Version 6.2.9200.20512 X86
Copyright (c) Microsoft Corporation. All rights reserved.
Opened \\.\COM1 …Run Code Online (Sandbox Code Playgroud) 这里的OP定义的功能round与作用floor在gnuplot.帮助floor说:
gnuplot> help floor
The `floor(x)` function returns the largest integer not greater than its
argument. For complex numbers, `floor` returns the largest integer not
greater than the real part of its argument.
Run Code Online (Sandbox Code Playgroud)
我怎么用floor我做的:
gnuplot> floor(7.3)
^
invalid command
Run Code Online (Sandbox Code Playgroud)
我可以以某种方式改变数字将舍入到的小数位数吗?
我想绘制x轴很长的数据.如果我绘制整个x轴,那么绘图会缩小,几乎不可读.我发现这对SO答案指向以下 SciPy的/ matplotlib代码.但是当我尝试运行上面提到的代码时,我得到以下错误:
Traceback (most recent call last):
File "scrollingPlot.py", line 88, in <module>
app = MyApp()
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 8628, in __init__
self._BootstrapApp()
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 8196, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "scrollingPlot.py", line 82, in OnInit
self.frame = MyFrame(parent=None,id=-1)
File "scrollingPlot.py", line 21, in __init__
self.scroll_range)
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 11226, in SetScrollbar
return _core_.Window_SetScrollbar(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "sb" failed at ../src/gtk/window.cpp(4754) in SetScrollbar(): this window is not scrollable
Run Code Online (Sandbox Code Playgroud)
PS:也欢迎其他解决方案(最好是python,R,或者简单的多平台)
PPS:我已经提到了上述错误的问题
我有这段代码,我可以在其中控制属性,例如:x 轴范围、标题、xlabel、ylabel、图例、网格、x 标签上的文本旋转:
#!/usr/bin/python
import datetime
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider
from matplotlib.dates import DateFormatter
############################################
# generate data
x = np.arange(0,10)
y0 = np.arange(0,10)
y1 = np.random.rand(10)
y2 = np.random.rand(10)
############################################
# initialize (sub)plot(s)
fig, ax = plt.subplots()
############################################
# width of x axis
x_min_index = 0
x_max_index = 3
x_min = x[x_min_index]
x_max = x[x_max_index]
############################################
# create (sub)plot
l, = plt.plot(x,y0, label="plot1a")
l, = plt.plot(x,y1, label="plot1b")
l, = …Run Code Online (Sandbox Code Playgroud) 我以前用awk处理csv文件,这是我的第一个脚本:
tail -n +2 shifted_final.csv | awk -F, 'BEGIN {old=$2} {if($2!=old){print $0; old=$2;}}' | less
Run Code Online (Sandbox Code Playgroud)
此脚本在第2列中查找重复值(如果第n行的值与第n + 1行,n + 2 ...相同),则仅打印第一次出现的值.例如,如果您输入以下输入:
ord,orig,pred,as,o-p
1,0,0,1.0,0
2,0,0,1.0,0
3,0,0,1.0,0
4,0,0,0.0,0
5,0,0,0.0,0
6,0,0,0.0,0
7,0,0,0.0,0
8,0,0,0.0,0
9,0,0,0.0,0
10,0,0,0.0,0
11,0,0,0.0,0
12,0,0,0.0,0
13,0,0,0.0,0
14,0,0,0.0,0
15,0,0,0.0,0
16,0,0,0.0,0
17,0,0,0.0,0
18,0,0,0.0,0
19,0,0,0.0,0
20,0,0,0.0,0
21,0,0,0.0,0
22,0,0,0.0,0
23,4,0,0.0,4
24,402,0,1.0,402
25,0,0,1.0,0
Run Code Online (Sandbox Code Playgroud)
然后输出将是:
1,0,0,1.0,0
23,4,0,0.0,4
24,402,0,1.0,402
25,0,0,1.0,0
Run Code Online (Sandbox Code Playgroud)
编辑: 我添加第二个脚本有点挑战:
第二个脚本执行相同操作但打印最后一次重复出现:
tail -n +2 shifted_final.csv | awk -F, 'BEGIN {old=$2; line=$0} {if($2==old){line=$0}else{print line; old=$2; line=$0}} END {print $0}' | less
Run Code Online (Sandbox Code Playgroud)
它的输出将是:
22,0,0,0.0,0
23,4,0,0.0,4
24,402,0,1.0,402
25,0,0,1.0,0
Run Code Online (Sandbox Code Playgroud)
我认为R是应该处理这些任务的强大语言,但我发现只有从R等调用awk脚本的问题.如何在R中执行此操作?
我有这样的数据:
set.seed(1)
a <- pnorm(seq(-2, 2, 0.05))
a[7] <- NA
a[19:24] <- NA
a
# [1] 0.02275013 0.02558806 0.02871656 0.03215677 0.03593032 0.04005916
# [7] NA 0.04947147 0.05479929 0.06057076 0.06680720 0.07352926
#[13] 0.08075666 0.08850799 0.09680048 0.10564977 0.11506967 0.12507194
#[19] NA NA NA NA NA NA
#[25] 0.21185540 0.22662735 0.24196365 0.25784611 0.27425312 0.29115969
#[31] 0.30853754 0.32635522 0.34457826 0.36316935 0.38208858 0.40129367
#[37] 0.42074029 0.44038231 0.46017216 0.48006119 0.50000000 0.51993881
#[43] 0.53982784 0.55961769 0.57925971 0.59870633 0.61791142 0.63683065
#[49] 0.65542174 0.67364478 0.69146246 0.70884031 0.72574688 0.74215389
#[55] …Run Code Online (Sandbox Code Playgroud) 我已经根据官方教程设置了单节点 kubernetes 。
除了官方文档,我还设置了单节点集群:
kubectl taint nodes --all node-role.kubernetes.io/master-
Run Code Online (Sandbox Code Playgroud)
残疾人驱逐限制:
cat << EOF >> /var/lib/kubelet/config.yaml
evictionHard:
imagefs.available: 1%
memory.available: 100Mi
nodefs.available: 1%
nodefs.inodesFree: 1%
EOF
systemctl daemon-reload
systemctl restart kubelet
Run Code Online (Sandbox Code Playgroud)
并为 Docker 设置 systemd 驱动程序:
cat << EOF > /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
systemctl daemon-reload
systemctl restart docker
Run Code Online (Sandbox Code Playgroud)
我试过以下:
docker build -t localhost:5000/my-image .
kubectl run -it --rm --restart=Always --image=localhost:5000/my-image my-image
Run Code Online (Sandbox Code Playgroud)
但是在 pod 日志中我看到ImagePullBackOff. 如果我设置了本地存储库并 …
我有以下代码:
#include <stdio.h>
int main()
{
int i;
char c;
char *format_string = "%d\n";
scanf(format_string, &i);
printf("read: %d\n", i);
printf("Let's check what is in the input buffer:\n");
while (scanf("%c", &c) == 1)
{
printf("read from input buf: %d\n", c);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我按以下方式运行代码:
echo "5" | ./specific.out
Run Code Online (Sandbox Code Playgroud)
输出如下:
read: 5
Let's check what is in the input buffer:
Run Code Online (Sandbox Code Playgroud)
这里我有上面代码的更通用版本,我从命令行传递格式字符串:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc != 2)
{
exit(EXIT_SUCCESS);
}
int i;
char c;
char …Run Code Online (Sandbox Code Playgroud)