我正在使用 bash 脚本来自动化一些任务。这就是我到目前为止所做的:
#!/usr/bin/env bash
PS3='Please enter your choice: '
options=("Create new group" "Add users to group" "Change directory ownership" "Change directory permissions" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Create new group")
read -e -p "Enter the group name: " -i "www-pub" groupname
groupadd groupname
echo "You have added a new group: " groupname
;;
"Add users to group")
## Here
;;
"Change directory ownership")
read -e -p "Enter the group name: " -i "www-pub" "Enter the …Run Code Online (Sandbox Code Playgroud) 我想在通过调用启动特定接口(例如 eth0)时运行网络脚本
ifup eth0
Run Code Online (Sandbox Code Playgroud)
该脚本只能在启动 eth0 时运行。我的方法是编写脚本(名为script.sh)将其作为可执行文件放置在某处,然后写入/etc/network/interfaces:
auto eth0
iface eth0 inet manual
up /path/to/script.sh
Run Code Online (Sandbox Code Playgroud)
有没有更优雅的方法来做到这一点?我可以/etc/network/if-up.d以某种方式使用脚本环境吗?据我所知,无论调出哪个界面,该文件夹中的所有脚本都将运行。
我正在尝试删除 apt-get 安装某些东西后 debian 发出的日志
Ign http://ftp.uk.debian.org jessie InRelease 点击 http://ftp.uk.debian.org jessie-updates InRelease 获取:1 http://security.debian.org jessie/updates InRelease [63.1 kB] 点击 http://ftp.uk.debian.org jessie Release.gpg 点击 http://ftp.uk.debian.org jessie-updates/main 来源 获取:2 http://ftp.uk.debian.org jessie-updates/main amd64 Packages/DiffIndex [3,472 B] 获取:3 http://ftp.uk.debian.org jessie-updates/main Translation-en/DiffIndex [1,720 B] 点击 http://ftp.uk.debian.org jessie 发布 获取:4 http://security.debian.org jessie/updates/main 来源 [131 kB] 点击 http://ftp.uk.debian.org jessie/main 来源 点击 http://ftp.uk.debian.org jessie/main amd64 软件包 点击 http://ftp.uk.debian.org jessie/main 翻译-en 获取:5 http://security.debian.org jessie/updates/main amd64 软件包 [237 kB] 获取:6 http://security.debian.org jessie/updates/main Translation-en [129 kB] 3 秒内获取 565 kB …
我有一个单行文件,其中的值存储为字符串:
server-name-2009-August-9-AMI
Run Code Online (Sandbox Code Playgroud)
文件名为server_name. 使用 bash 脚本将此值转换为变量的最短、最优雅的方法是什么?
当我开始工作时,我花了几分钟无聊的时间运行我的应用程序。我启动了 IDE、邮件客户端、Web 浏览器、错误跟踪系统、Total Commander、ProcessExplorer 和 DebugView。我在日常工作中使用的大多数工具。启动它们需要很长时间。
因此,我创建了一个 BAT 文件,并将调用所有这些应用程序放入其中。当我打开我的工作 PC 时,我就可以运行这个 BAT 并有时间做早间咖啡。尽管如此,我意识到使用 BAT 的第二个应用程序只有在第一个应用程序关闭后才会启动。由于我希望所有应用程序都启动,我是否可以使用 BAT 文件来启动它?我不想使用 Windows XP 的启动机制...
背景:
每个工作日我都会收到一封来自已知发件人的电子邮件。发件人在电子邮件中放入附件。我必须使用 python 脚本处理该附件。
题:
对我来说,将附件从 Outlook 中取出并放到我的 shell 帐户(或本地文件系统)上的最佳(自动)方法是什么,以便我可以使用脚本处理它,而不必每天手动打开文件并保存附件?
如果不使用 AD GPO(Active Directory 组策略对象)或类似工具,如何为 Windows 创建注销脚本?
这适用于个人环境中的 XP(家庭版和专业版)、Vista 和 7(即,在任何地方都看不到域控制器)。
我当前的项目在 linux 机器上运行一个测试系统(有 9 个活动屏幕)
整个团队都熟悉如何开始测试等。但不太熟悉用于检查进度、移动文件、强制停止测试等的命令。
我想编写一个脚本,可以将有用的检查放在一起,通过一个简单的按键来踢它们。我可以很容易地在 Perl 中做到这一点,但如果它是一个 shell 脚本 (bash),则更一致。
虽然我的 shell 经验有限,但我想要一个易于其他人扩展的示例脚本(即框架)。
Wait for Key
Perform action
Possibly accept further input for action
Repeat
Run Code Online (Sandbox Code Playgroud)
如果没有收到密钥,则每 n 分钟运行一次操作。
我正在寻找一种工具或脚本(Textwrangler 或终端),它可以从第 5 行开始每 100 行拆分一个较大的文本文件(前 4 行是标题行)并输出包含原始标题的单个 .txt 文件。
例如
输入:
File.txt
line1 / line4 HEADER
...
line5 / line265 DATA
Run Code Online (Sandbox Code Playgroud)
输出:
File_01.txt
line1/line4 HEADER
line5/line104 DATA
File_02.txt
line1/line4 HEADER
line5/line104 DATA
File_03.txt
line1/line4 HEADER
line5/line65 DATA
Run Code Online (Sandbox Code Playgroud)
文本文件使用 Windows 换行符 (CR LF) 以防万一。
我目前正在手动执行此操作,因此非常欢迎任何可以提高此过程效率的建议。
我正在寻找一个脚本(或 Launchbar 操作或应用程序),它将从任何应用程序的前窗口获取突出显示的文本并将其发送到我的默认浏览器以在 Google 中进行搜索。我希望能够将它绑定到系统范围的键盘快捷键。我希望能够突出显示一些文本,按一个键并在我的浏览器中打开 Google 结果。
script ×10
linux ×4
automation ×2
bash ×2
macos ×2
attachments ×1
boot ×1
centos ×1
debian ×1
email ×1
installation ×1
networking ×1
search ×1
shell ×1
shell-script ×1
text-editing ×1
textwrangler ×1
windows ×1
windows-xp ×1