小编jah*_*hil的帖子

GNU Screen - 在shell或脚本的后台运行命令中创建屏幕

我正在尝试screen从shell 创建一个会话/窗口并在其中启动一个命令.我该怎么办?

bash shell gnu-screen

13
推荐指数
1
解决办法
2万
查看次数

python TypeError没有足够的格式字符串参数

试图用python fabric更新文件

run('sed -i s/jahil/%s/g /etc/nginx/sites-enabled/%s' % (account))
Run Code Online (Sandbox Code Playgroud)

要么

run('sed -i "s/jahil/%s/g" /etc/nginx/sites-enabled/%s' % (account))
Run Code Online (Sandbox Code Playgroud)

错误:

TypeError: not enough arguments for format string
Run Code Online (Sandbox Code Playgroud)

任何的想法 ?非常感谢 !

python regex sed fabric

1
推荐指数
1
解决办法
2119
查看次数

python字符串转换

尝试使用python fabric脚本添加用户.

uid = prompt("Enter username:")
eid = prompt("Enter user's email address:")
password = generate_passwd()
run('adduser -g vpn -c %s %s') % (eid, uid)
run("echo -e '%s\n' | passwd %s") % (password, uid)
print (password)
Run Code Online (Sandbox Code Playgroud)

错误:

File "/tmp/hardway/fabfile.py", line 56, in addvpnuser
    run('adduser -g vpn -c %s %s') % (eid, uid)
TypeError: not all arguments converted during string formatting
Run Code Online (Sandbox Code Playgroud)

知道我做错了什么.提前致谢.

python fabric

0
推荐指数
1
解决办法
294
查看次数

如何修复"TypeError:不支持的操作数类型"?

我正在尝试在file.write函数中使用var值:

profile = open("/tmp/%s.pcf", 'w+') % uid
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

TypeError: unsupported operand type(s) for %: 'file' and 'str'
Run Code Online (Sandbox Code Playgroud)

知道我做错了什么吗?

python

0
推荐指数
1
解决办法
280
查看次数

标签 统计

python ×3

fabric ×2

bash ×1

gnu-screen ×1

regex ×1

sed ×1

shell ×1