From 64e0a8551794ca7ab4d3c942395537475f3bce05 Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 25 Mar 2018 23:27:26 +0800 Subject: [PATCH 1/5] pygmalion666 translating Translating 15% of the article "20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts" --- ... Spice To Your UNIX-Linux Shell Scripts.md | 392 ++++++++++++++++++ 1 file changed, 392 insertions(+) create mode 100644 translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md new file mode 100644 index 0000000000..3735494dee --- /dev/null +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -0,0 +1,392 @@ +# 10 个给 UNIX-Linux Shell 脚本增加趣味的工具 + +====== + +There are some misconceptions that shell scripts are only for a CLI environment. You can efficiently use various tools to write GUI and network (socket) scripts under KDE or Gnome desktops. Shell scripts can make use of some of the GUI widget (menus, warning boxes, progress bars, etc.). You can always control the final output, cursor position on the screen, various output effects, and more. With the following tools, you can build powerful, interactive, user-friendly UNIX / Linux bash shell scripts. + +有些误解认为 shell 脚本仅适用于命令行环境。你可以在 KDE 或者 Gnome 桌面下有效的使用各种工具编写 GUI 或者网络(socket)脚本。shell 脚本可以利用一些 GUI 的组件(菜单、警告框、状态栏等等)。你可以一直控制屏幕最终输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户有好的 UNIX / Linux bash 脚本。 + +Creating GUI application is not an expensive task but a task that takes time and patience. Luckily, both UNIX and Linux ships with plenty of tools to write beautiful GUI scripts. The following tools are tested on FreeBSD and Linux operating systems but should work under other UNIX like operating systems. + +制作 GUI 应用不是一个昂贵任务,但是需要时间和耐心。幸运的是,UNIX 和 Linux 都附带有大量写漂亮 GUI 脚本的工具。以下工具在 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 + +## 1. notify-send 命令 + +The notify-send command allows you to send desktop notifications to the user via a notification daemon from the command line. This is useful to inform the desktop user about an event or display some form of information without getting in the user's way. You need to install the following package on a Debian/Ubuntu Linux using [apt command][1]/[apt-get command][2]: + +notify-send 命令允许你通过通知守护进程发送桌面通知给用户。这种通知桌面用户一个事件或者显示一些信息,而避免侵入用户的方式是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt][1] 或 [apt-get][2] 命令安装下面的包: + +`$ sudo apt-get install libnotify-bin` +CentOS/RHEL user try the following [yum command][3]: +`$ sudo yum install libnotify` +Fedora Linux user type the following dnf command: +`$ sudo dnf install libnotify` +In this example, send simple desktop notification from the command line, enter: +``` +### send some notification ## +notify-send "rsnapshot done :)" +``` + +Sample outputs: +![Fig:01: notify-send in action ][4] +Here is another code with additional options: +``` +.... +alert=18000 +live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's/,//g;s/\.[0-9]*//g') +[ $notify_counter -eq 0 ] && [ $live -ge $alert ] && { notify-send -t 5000 -u low -i "BSE Sensex touched 18k"; notify_counter=1; } +... +``` + +Sample outputs: +![Fig.02: notify-send with timeouts and other options][5] +Where, + + * -t 5000: Specifies the timeout in milliseconds ( 5000 milliseconds = 5 seconds) + * -u low : Set the urgency level (i.e. low, normal, or critical). + * -i gtk-dialog-info : Set an icon filename or stock icon to display (you can set path as -i /path/to/your-icon.png). + + + +For more information on use of the notify-send utility, please refer to the notify-send man page, viewable by typing man notify-send from the command line: +``` +man notify-send +``` + +### #2: tput Command + +The tput command is used to set terminal features. With tput you can set: + + * Move the cursor around the screen. + * Get information about terminal. + * Set colors (background and foreground). + * Set bold mode. + * Set reverse mode and much more. + + + +Here is a sample code: +``` +#!/bin/bash + +# clear the screen +tput clear + +# Move cursor to screen location X,Y (top left is 0,0) +tput cup 3 15 + +# Set a foreground colour using ANSI escape +tput setaf 3 +echo "XYX Corp LTD." +tput sgr0 + +tput cup 5 17 +# Set reverse video mode +tput rev +echo "M A I N - M E N U" +tput sgr0 + +tput cup 7 15 +echo "1. User Management" + +tput cup 8 15 +echo "2. Service Management" + +tput cup 9 15 +echo "3. Process Management" + +tput cup 10 15 +echo "4. Backup" + +# Set bold mode +tput bold +tput cup 12 15 +read -p "Enter your choice [1-4] " choice + +tput clear +tput sgr0 +tput rc +``` + + +Sample outputs: +![Fig.03: tput in action][6] +For more detail concerning the tput command, see the following man page: +``` +man 5 terminfo +man tput +``` + +### #3: setleds Command + +The setleds command allows you to set the keyboard leds. In this example, set NumLock on: +``` +setleds -D +num +``` + +To turn it off NumLock, enter: +``` +setleds -D -num +``` + + * -caps : Clear CapsLock. + * +caps : Set CapsLock. + * -scroll : Clear ScrollLock. + * +scroll : Set ScrollLock. + + + +See setleds command man page for more information and options: +`man setleds` + +### #4: zenity Command + +The [zenity commadn will display GTK+ dialogs box][7], and return the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts. Here is a sample GUI client for the whois directory service for given domain name: + +```shell +#!/bin/bash +# Get domain name +_zenity="/usr/bin/zenity" +_out="/tmp/whois.output.$$" +domain=$(${_zenity} --title "Enter domain" \ + --entry --text "Enter the domain you would like to see whois info" ) + +if [ $? -eq 0 ] +then + # Display a progress dialog while searching whois database + whois $domain | tee >(${_zenity} --width=200 --height=100 \ + --title="whois" --progress \ + --pulsate --text="Searching domain info..." \ + --auto-kill --auto-close \ + --percentage=10) >${_out} + + # Display back output + ${_zenity} --width=800 --height=600 \ + --title "Whois info for $domain" \ + --text-info --filename="${_out}" +else + ${_zenity} --error \ + --text="No input provided" +fi +``` + +Sample outputs: +![Fig.04: zenity in Action][8] +See the zenity man page for more information and all other supports GTK+ widgets: +``` +zenity --help +man zenity +``` + +### #5: kdialog Command + +kdialog is just like zenity but it is designed for KDE desktop / qt apps. You can display dialogs using kdialog. The following will display message on screen: +``` +kdialog --dontagain myscript:nofilemsg --msgbox "File: '~/.backup/config' not found." +``` + +Sample outputs: +![Fig.05: Suppressing the display of a dialog ][9] + +See [shell scripting with KDE Dialogs][10] tutorial for more information. + +### #6: Dialog + +[Dialog is an application used in shell scripts][11] which displays text user interface widgets. It uses the curses or ncurses library. Here is a sample code: +``` +#!/bin/bash +dialog --title "Delete file" \ +--backtitle "Linux Shell Script Tutorial Example" \ +--yesno "Are you sure you want to permanently delete \"/tmp/foo.txt\"?" 7 60 + +# Get exit status +# 0 means user hit [yes] button. +# 1 means user hit [no] button. +# 255 means user hit [Esc] key. +response=$? +case $response in + 0) echo "File deleted.";; + 1) echo "File not deleted.";; + 255) echo "[ESC] key pressed.";; +esac +``` + +See the dialog man page for details: +`man dialog` + +#### A Note About Other User Interface Widgets Tools + +UNIX and Linux comes with lots of other tools to display and control apps from the command line, and shell scripts can make use of some of the KDE / Gnome / X widget set: + + * **gmessage** - a GTK-based xmessage clone. + * **xmessage** - display a message or query in a window (X-based /bin/echo) + * **whiptail** - display dialog boxes from shell scripts + * **python-dialog** - Python module for making simple Text/Console-mode user interfaces + + + +### #7: logger command + +The logger command writes entries in the system log file such as /var/log/messages. It provides a shell command interface to the syslog system log module: +``` +logger "MySQL database backup failed." +tail -f /var/log/messages +logger -t mysqld -p daemon.error "Database Server failed" +tail -f /var/log/syslog +``` + +Sample outputs: +``` +Apr 20 00:11:45 vivek-desktop kernel: [38600.515354] CPU0: Temperature/speed normal +Apr 20 00:12:20 vivek-desktop mysqld: Database Server failed +``` + +See howto [write message to a syslog / log file][12] for more information. Alternatively, you can see the logger man page for details: +`man logger` + +### #8: setterm Command + +The setterm command can set various terminal attributes. In this example, force screen to turn black in 15 minutes. Monitor standby will occur at 60 minutes: +``` +setterm -blank 15 -powersave powerdown -powerdown 60 +``` + +In this example show underlined text for xterm window: +``` +setterm -underline on; +echo "Add Your Important Message Here" +setterm -underline off +``` + +Another useful option is to turn on or off cursor: +``` +setterm -cursor off +``` + +Turn it on: +``` +setterm -cursor on +``` + +See the setterm command man page for details: +`man setterm` + +### #9: smbclient: Sending Messages To MS-Windows Workstations + +The smbclient command can talk to an SMB/CIFS server. It can send a message to selected users or all users on MS-Windows systems: +``` +smbclient -M WinXPPro </dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 open" || echo "TCP port 25 close" +``` + +You can use [bash loop and find out open ports][14] with the snippets: +``` +echo "Scanning TCP ports..." +for p in {1..1023} +do + (echo >/dev/tcp/localhost/$p) >/dev/null 2>&1 && echo "$p open" +done +``` + + +Sample outputs: +``` +Scanning TCP ports... +22 open +53 open +80 open +139 open +445 open +631 open +``` + +In this example, your bash script act as an HTTP client: +``` +#!/bin/bash +exec 3<> /dev/tcp/${1:-www.cyberciti.biz}/80 + +printf "GET / HTTP/1.0\r\n" >&3 +printf "Accept: text/html, text/plain\r\n" >&3 +printf "Accept-Language: en\r\n" >&3 +printf "User-Agent: nixCraft_BashScript v.%s\r\n" "${BASH_VERSION}" >&3 +printf "\r\n" >&3 + +while read LINE <&3 +do + # do something on $LINE + # or send $LINE to grep or awk for grabbing data + # or simply display back data with echo command + echo $LINE +done +``` + +See the bash man page for more information: +`man bash` + +### A Note About GUI Tools and Cronjob + +You need to request local display/input service using export DISPLAY=[user's machine]:0 command if you are [using cronjob][15] to call your scripts. For example, call /home/vivek/scripts/monitor.stock.sh as follows which uses zenity tool: +`@hourly DISPLAY=:0.0 /home/vivek/scripts/monitor.stock.sh` + +Have a favorite UNIX tool to spice up shell script? Share it in the comments below. + +### about the author + +The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][16], [Facebook][17], [Google+][18]. + +-------------------------------------------------------------------------------- + +via: https://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html + +作者:[Vivek Gite][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.cyberciti.biz +[1]:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) +[2]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) +[3]:https://www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/ (See Linux/Unix yum command examples for more info) +[4]:https://www.cyberciti.biz/media/new/tips/2010/04/notify-send.png (notify-send: Shell Script Get Or Send Desktop Notifications ) +[5]:https://www.cyberciti.biz/media/new/tips/2010/04/notify-send-with-icons-timeout.png (Linux / UNIX: Display Notifications From Your Shell Scripts With notify-send) +[6]:https://www.cyberciti.biz/media/new/tips/2010/04/tput-options.png (Linux / UNIX Script Colours and Cursor Movement With tput) +[7]:https://bash.cyberciti.biz/guide/Zenity:_Shell_Scripting_with_Gnome +[8]:https://www.cyberciti.biz/media/new/tips/2010/04/zenity-outputs.png (zenity: Linux / UNIX display Dialogs Boxes From The Shell Scripts) +[9]:https://www.cyberciti.biz/media/new/tips/2010/04/KDialog.png (Kdialog: Suppressing the display of a dialog ) +[10]:http://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs +[11]:https://bash.cyberciti.biz/guide/Bash_display_dialog_boxes +[12]:https://www.cyberciti.biz/tips/howto-linux-unix-write-to-syslog.html +[13]:https://www.cyberciti.biz/tips/freebsd-sending-a-message-to-windows-workstation.html +[14]:https://www.cyberciti.biz/faq/bash-for-loop/ +[15]:https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/ +[16]:https://twitter.com/nixcraft +[17]:https://facebook.com/nixcraft +[18]:https://plus.google.com/+CybercitiBiz \ No newline at end of file From 4ad74d50a0e365b3733317f6f81ffa9f7a3c91c2 Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 1 Apr 2018 17:59:50 +0800 Subject: [PATCH 2/5] Translated by pygmalion666 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts” 翻译完成,请校对。 --- ... Spice To Your UNIX-Linux Shell Scripts.md | 275 ++++++++++-------- 1 file changed, 150 insertions(+), 125 deletions(-) diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md index 3735494dee..7d9e374c3e 100644 --- a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -1,36 +1,40 @@ -# 10 个给 UNIX-Linux Shell 脚本增加趣味的工具 - +# 10 个增加 UNIX/Linux Shell 脚本趣味的工具 ====== -There are some misconceptions that shell scripts are only for a CLI environment. You can efficiently use various tools to write GUI and network (socket) scripts under KDE or Gnome desktops. Shell scripts can make use of some of the GUI widget (menus, warning boxes, progress bars, etc.). You can always control the final output, cursor position on the screen, various output effects, and more. With the following tools, you can build powerful, interactive, user-friendly UNIX / Linux bash shell scripts. +有些误解认为 Shell 脚本仅用于 CLI 环境。实际上在 KDE 或 Gnome 桌面下,你可以有效的使用各种工具编写 GUI 或者网络(socket)脚本。Shell 脚本可以使用一些 GUI 组件(菜单、警告框、进度条等),你可以控制终端输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户友好的 UNIX/Linux bash 脚本。 -有些误解认为 shell 脚本仅适用于命令行环境。你可以在 KDE 或者 Gnome 桌面下有效的使用各种工具编写 GUI 或者网络(socket)脚本。shell 脚本可以利用一些 GUI 的组件(菜单、警告框、状态栏等等)。你可以一直控制屏幕最终输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户有好的 UNIX / Linux bash 脚本。 +制作 GUI 应用不是一项昂贵的任务,但需要时间和耐心。幸运的是,UNIX 和 Linux 都带有大量编写漂亮 GUI 脚本的工具。以下工具是基于 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 -Creating GUI application is not an expensive task but a task that takes time and patience. Luckily, both UNIX and Linux ships with plenty of tools to write beautiful GUI scripts. The following tools are tested on FreeBSD and Linux operating systems but should work under other UNIX like operating systems. +### 1. notify-send 命令 -制作 GUI 应用不是一个昂贵任务,但是需要时间和耐心。幸运的是,UNIX 和 Linux 都附带有大量写漂亮 GUI 脚本的工具。以下工具在 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 +notify-send 命令允许你使用通知守护进程发送桌面通知给用户。这种避免侵入用户的方式,对于通知桌面用户一个事件或显示一些信息是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt 命令][1] 或 [apt-get 命令][2] 安装的包: -## 1. notify-send 命令 +```bash +sudo apt-get install libnotify-bin +``` -The notify-send command allows you to send desktop notifications to the user via a notification daemon from the command line. This is useful to inform the desktop user about an event or display some form of information without getting in the user's way. You need to install the following package on a Debian/Ubuntu Linux using [apt command][1]/[apt-get command][2]: +CentOS/RHEL 用户使用下面的 [yum 命令][3]: -notify-send 命令允许你通过通知守护进程发送桌面通知给用户。这种通知桌面用户一个事件或者显示一些信息,而避免侵入用户的方式是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt][1] 或 [apt-get][2] 命令安装下面的包: +```bash +sudo yum install libnotify +``` -`$ sudo apt-get install libnotify-bin` -CentOS/RHEL user try the following [yum command][3]: -`$ sudo yum install libnotify` -Fedora Linux user type the following dnf command: +Fedora Linux 用户使用下面的 dnf 命令: + +```bash `$ sudo dnf install libnotify` In this example, send simple desktop notification from the command line, enter: -``` ### send some notification ## notify-send "rsnapshot done :)" ``` -Sample outputs: +示例输出: + ![Fig:01: notify-send in action ][4] -Here is another code with additional options: -``` + +下面是另一个附加选项的代码: + +```bash .... alert=18000 live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's/,//g;s/\.[0-9]*//g') @@ -38,119 +42,122 @@ live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5} ... ``` -Sample outputs: +示例输出: + ![Fig.02: notify-send with timeouts and other options][5] -Where, - * -t 5000: Specifies the timeout in milliseconds ( 5000 milliseconds = 5 seconds) - * -u low : Set the urgency level (i.e. low, normal, or critical). - * -i gtk-dialog-info : Set an icon filename or stock icon to display (you can set path as -i /path/to/your-icon.png). +这里: + * -t 5000: 指定超时时间(毫秒) (5000 毫秒 = 5 秒) + * -u low : 设置紧急等级 (如:低、普通、紧急) + * -i gtk-dialog-info : 设置要显示的图标名称或者指定的图标(你可以设置路径为:-i /path/to/your-icon.png) +关于更多使用 notify-send 功能的信息,请参考 notify-send 手册。在命令行下输入 `man notify-send` 即可看见: -For more information on use of the notify-send utility, please refer to the notify-send man page, viewable by typing man notify-send from the command line: -``` +```bash man notify-send ``` -### #2: tput Command +### #2:tput 命令 -The tput command is used to set terminal features. With tput you can set: +tput 命令用于设置终端特性。通过 tput 你可以设置: - * Move the cursor around the screen. - * Get information about terminal. - * Set colors (background and foreground). - * Set bold mode. - * Set reverse mode and much more. + * 在屏幕上移动光标。 + * 获取终端信息。 + * 设置颜色(背景和前景)。 + * 设置加粗模式。 + * 设置反向模式等等。 +下面有一段示例代码: - -Here is a sample code: -``` +```bash #!/bin/bash - + # clear the screen tput clear - + # Move cursor to screen location X,Y (top left is 0,0) tput cup 3 15 - + # Set a foreground colour using ANSI escape tput setaf 3 echo "XYX Corp LTD." tput sgr0 - + tput cup 5 17 # Set reverse video mode tput rev echo "M A I N - M E N U" tput sgr0 - + tput cup 7 15 echo "1. User Management" - + tput cup 8 15 echo "2. Service Management" - + tput cup 9 15 echo "3. Process Management" - + tput cup 10 15 echo "4. Backup" - + # Set bold mode tput bold tput cup 12 15 read -p "Enter your choice [1-4] " choice - + tput clear tput sgr0 tput rc ``` +示例输出: -Sample outputs: ![Fig.03: tput in action][6] -For more detail concerning the tput command, see the following man page: -``` + +关于 tput 命令的详细信息,参见手册: + +```bash man 5 terminfo man tput ``` -### #3: setleds Command +### #3:setleds 命令 -The setleds command allows you to set the keyboard leds. In this example, set NumLock on: -``` +setleds 命令允许你设置键盘灯。下面是打开数字键灯的示例: + +```bash setleds -D +num ``` -To turn it off NumLock, enter: -``` +关闭数字键灯,输入: + +```bash setleds -D -num ``` - * -caps : Clear CapsLock. - * +caps : Set CapsLock. - * -scroll : Clear ScrollLock. - * +scroll : Set ScrollLock. + * -caps:关闭大小写锁定 + * +caps:打开大小写锁定 + * -scroll:关闭滚动锁定 + * +scroll:打开滚动锁定 +查看 setleds 手册可看见更多信息和选项: - -See setleds command man page for more information and options: `man setleds` -### #4: zenity Command +### #4:zenity 命令 -The [zenity commadn will display GTK+ dialogs box][7], and return the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts. Here is a sample GUI client for the whois directory service for given domain name: +[zenity 命令显示 GTK+ 对话框][7],并且返回用户输入。它允许你使用各种 Shell 脚本向用户展示或请求信息。下面是 whois 指定域名目录服务的 GUI 客户端示例。 -```shell +```bash #!/bin/bash # Get domain name _zenity="/usr/bin/zenity" _out="/tmp/whois.output.$$" domain=$(${_zenity} --title "Enter domain" \ - --entry --text "Enter the domain you would like to see whois info" ) - + --entry --text "Enter the domain you would like to see whois info" ) + if [ $? -eq 0 ] then # Display a progress dialog while searching whois database @@ -170,30 +177,36 @@ else fi ``` -Sample outputs: +示例输出: + ![Fig.04: zenity in Action][8] -See the zenity man page for more information and all other supports GTK+ widgets: -``` + +参见手册获取更多 zenity 信息以及其他支持 GTK+ 的组件: + +```bash zenity --help man zenity ``` -### #5: kdialog Command +### #5:kdialog 命令 -kdialog is just like zenity but it is designed for KDE desktop / qt apps. You can display dialogs using kdialog. The following will display message on screen: -``` +kdialog 命令与 zenity 类似,但它是为 KDE 桌面和 QT 应用设计。你可以使用 kdialog 展示对话框。下面示例将在屏幕上显示信息: + +```bash kdialog --dontagain myscript:nofilemsg --msgbox "File: '~/.backup/config' not found." ``` -Sample outputs: +示例输出: + ![Fig.05: Suppressing the display of a dialog ][9] -See [shell scripting with KDE Dialogs][10] tutorial for more information. +参见 《[KDE 对话框 Shell 脚本编程][10]》 教程获取更多信息。 -### #6: Dialog +### #6:Dialog -[Dialog is an application used in shell scripts][11] which displays text user interface widgets. It uses the curses or ncurses library. Here is a sample code: -``` +[Dialog 是一个使用 Shell 脚本的应用][11],显示用户界面组件的文本。它使用 curses 或者 ncurses 库。下面是一个示例代码: + +```bash #!/bin/bash dialog --title "Delete file" \ --backtitle "Linux Shell Script Tutorial Example" \ @@ -211,70 +224,77 @@ case $response in esac ``` -See the dialog man page for details: +参见 dialog 手册获取详细信息: `man dialog` -#### A Note About Other User Interface Widgets Tools +### 关于其他用户界面工具的注意事项 -UNIX and Linux comes with lots of other tools to display and control apps from the command line, and shell scripts can make use of some of the KDE / Gnome / X widget set: +UNIX、Linux 提供了大量其他工具来显示和控制命令行中的应用程序,shell 脚本可以使用一些 KDE、Gnome、X 组件集: - * **gmessage** - a GTK-based xmessage clone. - * **xmessage** - display a message or query in a window (X-based /bin/echo) - * **whiptail** - display dialog boxes from shell scripts - * **python-dialog** - Python module for making simple Text/Console-mode user interfaces + * **gmessage** - 基于 GTK xmessage 的克隆. + * **xmessage** - 在窗口中显示或查询消息(X-based /bin/echo) + * **whiptail** - 显示来自 shell 脚本的对话框 + * **python-dialog** - 用于制作简单文本或控制台模式用户界面的 Python 模块 +### #7:logger 命令 +logger 命令将信息写到系统日志文件,如: /var/log/messages。它为系统日志模块 syslog 提供了一个 shell 命令行接口: -### #7: logger command - -The logger command writes entries in the system log file such as /var/log/messages. It provides a shell command interface to the syslog system log module: -``` +```bash logger "MySQL database backup failed." tail -f /var/log/messages logger -t mysqld -p daemon.error "Database Server failed" tail -f /var/log/syslog ``` -Sample outputs: -``` +示例输出: + +```bash Apr 20 00:11:45 vivek-desktop kernel: [38600.515354] CPU0: Temperature/speed normal Apr 20 00:12:20 vivek-desktop mysqld: Database Server failed ``` -See howto [write message to a syslog / log file][12] for more information. Alternatively, you can see the logger man page for details: +参见 《[如何写消息到 syslog 或 日志文件][12]》 获得更多信息。此外,你也可以查看 logger 手册获取详细信息: + `man logger` -### #8: setterm Command +### #8:setterm 命令 -The setterm command can set various terminal attributes. In this example, force screen to turn black in 15 minutes. Monitor standby will occur at 60 minutes: -``` +setterm 命令可设置不同的终端属性。下面的示例代码会强制屏幕在 15分钟后变黑,监视器则待机 60 分钟。 + +```bash setterm -blank 15 -powersave powerdown -powerdown 60 ``` -In this example show underlined text for xterm window: -``` +下面的例子将 xterm 窗口中的文本带有下划线展示: + +```bash setterm -underline on; echo "Add Your Important Message Here" setterm -underline off ``` -Another useful option is to turn on or off cursor: -``` +另一个有用的选项是打开或关闭光标: + +```bash setterm -cursor off ``` -Turn it on: -``` +打开光标: + +```bash setterm -cursor on ``` -See the setterm command man page for details: +参见 setterm 命令手册获取详细信息: + `man setterm` -### #9: smbclient: Sending Messages To MS-Windows Workstations +### #9:smbclient:给 MS-Windows 工作站发送消息 -The smbclient command can talk to an SMB/CIFS server. It can send a message to selected users or all users on MS-Windows systems: -``` +smbclient 命令可以与 SMB/CIFS 服务器通讯。它可以向 MS-Windows 系统上选定或全部用户发送消息。 + +```bash smbclient -M WinXPPro </dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 open" || echo "TCP port 25 close" ``` -You can use [bash loop and find out open ports][14] with the snippets: -``` +下面的代码片段,你可以利用 [bash 循环找出已打开的端口][14]: + +```bash echo "Scanning TCP ports..." for p in {1..1023} do @@ -315,9 +337,9 @@ do done ``` +示例输出: -Sample outputs: -``` +```bash Scanning TCP ports... 22 open 53 open @@ -327,17 +349,18 @@ Scanning TCP ports... 631 open ``` -In this example, your bash script act as an HTTP client: -``` +下面的示例中,你的 bash 脚本将像 HTTP 客户端一样工作: + +```bash #!/bin/bash exec 3<> /dev/tcp/${1:-www.cyberciti.biz}/80 - + printf "GET / HTTP/1.0\r\n" >&3 printf "Accept: text/html, text/plain\r\n" >&3 printf "Accept-Language: en\r\n" >&3 printf "User-Agent: nixCraft_BashScript v.%s\r\n" "${BASH_VERSION}" >&3 printf "\r\n" >&3 - + while read LINE <&3 do # do something on $LINE @@ -347,26 +370,28 @@ do done ``` -See the bash man page for more information: +参见 bash 手册获取更多信息: + `man bash` -### A Note About GUI Tools and Cronjob +### 关于 GUI 工具和 Cronjob 的注意事项 + +如果你 [使用 crontab][15] 来启动你的脚本,你需要使用 `export DISPLAY=[用户机器]:0` 命令请求本地显示或输出服务。举个例子,使用 zenity 工具调用 /home/vivek/scripts/monitor.stock.sh: -You need to request local display/input service using export DISPLAY=[user's machine]:0 command if you are [using cronjob][15] to call your scripts. For example, call /home/vivek/scripts/monitor.stock.sh as follows which uses zenity tool: `@hourly DISPLAY=:0.0 /home/vivek/scripts/monitor.stock.sh` -Have a favorite UNIX tool to spice up shell script? Share it in the comments below. +你有喜欢的可以增加 shell 脚本趣味的 UNIX 工具么?请在下面的评论区分享它吧。 -### about the author +### 关于作者 -The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][16], [Facebook][17], [Google+][18]. +本文作者是 nixCraft 创始人、一个老练的系统管理员、Linux 操作系统和 UNIX shell 编程培训师。他服务来自全球的客户和不同的行业,包括 IT 、教育、防务和空间探索、还有非营利组织。你可以在 [Twitter][16],[Facebook][17],[Google+][18] 上面关注他。 -------------------------------------------------------------------------------- via: https://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html 作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) +译者:[译者ID](https://github.com/pygmalion666) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 53aa2fd3d41c239d063d318e20198d215d7d12aa Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 1 Apr 2018 18:03:49 +0800 Subject: [PATCH 3/5] Updated by pygmalion666 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正 shell 大小写 --- ... Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md index 7d9e374c3e..03c2a345e2 100644 --- a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -1,7 +1,7 @@ # 10 个增加 UNIX/Linux Shell 脚本趣味的工具 ====== -有些误解认为 Shell 脚本仅用于 CLI 环境。实际上在 KDE 或 Gnome 桌面下,你可以有效的使用各种工具编写 GUI 或者网络(socket)脚本。Shell 脚本可以使用一些 GUI 组件(菜单、警告框、进度条等),你可以控制终端输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户友好的 UNIX/Linux bash 脚本。 +有些误解认为 shell 脚本仅用于 CLI 环境。实际上在 KDE 或 Gnome 桌面下,你可以有效的使用各种工具编写 GUI 或者网络(socket)脚本。shell 脚本可以使用一些 GUI 组件(菜单、警告框、进度条等),你可以控制终端输出、光标位置以及各种输出效果等等。利用下面的工具,你可以构建强壮的、可交互的、对用户友好的 UNIX/Linux bash 脚本。 制作 GUI 应用不是一项昂贵的任务,但需要时间和耐心。幸运的是,UNIX 和 Linux 都带有大量编写漂亮 GUI 脚本的工具。以下工具是基于 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 From f966a3cec90dc71212ff1d7292fd2393a331b0a6 Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 1 Apr 2018 18:07:08 +0800 Subject: [PATCH 4/5] Update by pygmalion666 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修正 H3 标题 --- ... Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md index 03c2a345e2..bed5385d90 100644 --- a/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ b/translated/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md @@ -5,7 +5,7 @@ 制作 GUI 应用不是一项昂贵的任务,但需要时间和耐心。幸运的是,UNIX 和 Linux 都带有大量编写漂亮 GUI 脚本的工具。以下工具是基于 FreeBSD 和 Linux 操作系统做的测试,而且也适用于其他类 UNIX 操作系统。 -### 1. notify-send 命令 +### 1#:notify-send 命令 notify-send 命令允许你使用通知守护进程发送桌面通知给用户。这种避免侵入用户的方式,对于通知桌面用户一个事件或显示一些信息是有用的。在 Debian 或 Ubuntu 上,你需要使用 [apt 命令][1] 或 [apt-get 命令][2] 安装的包: From 86900eec8d91ac123a371765dc57ba43aef11fe1 Mon Sep 17 00:00:00 2001 From: "[andyluo]" Date: Sun, 1 Apr 2018 18:12:11 +0800 Subject: [PATCH 5/5] Delete source: 20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 删除原始文档 --- ... Spice To Your UNIX-Linux Shell Scripts.md | 384 ------------------ 1 file changed, 384 deletions(-) delete mode 100644 sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md diff --git a/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md b/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md deleted file mode 100644 index 138215d9ec..0000000000 --- a/sources/tech/20100419 10 Tools To Add Some Spice To Your UNIX-Linux Shell Scripts.md +++ /dev/null @@ -1,384 +0,0 @@ -【Pgmalion666 Translating】 -10 Tools To Add Some Spice To Your UNIX/Linux Shell Scripts -====== -There are some misconceptions that shell scripts are only for a CLI environment. You can efficiently use various tools to write GUI and network (socket) scripts under KDE or Gnome desktops. Shell scripts can make use of some of the GUI widget (menus, warning boxes, progress bars, etc.). You can always control the final output, cursor position on the screen, various output effects, and more. With the following tools, you can build powerful, interactive, user-friendly UNIX / Linux bash shell scripts. - -Creating GUI application is not an expensive task but a task that takes time and patience. Luckily, both UNIX and Linux ships with plenty of tools to write beautiful GUI scripts. The following tools are tested on FreeBSD and Linux operating systems but should work under other UNIX like operating systems. - -### 1. notify-send Command - -The notify-send command allows you to send desktop notifications to the user via a notification daemon from the command line. This is useful to inform the desktop user about an event or display some form of information without getting in the user's way. You need to install the following package on a Debian/Ubuntu Linux using [apt command][1]/[apt-get command][2]: -`$ sudo apt-get install libnotify-bin` -CentOS/RHEL user try the following [yum command][3]: -`$ sudo yum install libnotify` -Fedora Linux user type the following dnf command: -`$ sudo dnf install libnotify` -In this example, send simple desktop notification from the command line, enter: -``` -### send some notification ## -notify-send "rsnapshot done :)" -``` - -Sample outputs: -![Fig:01: notify-send in action ][4] -Here is another code with additional options: -``` -.... -alert=18000 -live=$(lynx --dump http://money.rediff.com/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's/,//g;s/\.[0-9]*//g') -[ $notify_counter -eq 0 ] && [ $live -ge $alert ] && { notify-send -t 5000 -u low -i "BSE Sensex touched 18k"; notify_counter=1; } -... -``` - -Sample outputs: -![Fig.02: notify-send with timeouts and other options][5] -Where, - - * -t 5000: Specifies the timeout in milliseconds ( 5000 milliseconds = 5 seconds) - * -u low : Set the urgency level (i.e. low, normal, or critical). - * -i gtk-dialog-info : Set an icon filename or stock icon to display (you can set path as -i /path/to/your-icon.png). - - - -For more information on use of the notify-send utility, please refer to the notify-send man page, viewable by typing man notify-send from the command line: -``` -man notify-send -``` - -### #2: tput Command - -The tput command is used to set terminal features. With tput you can set: - - * Move the cursor around the screen. - * Get information about terminal. - * Set colors (background and foreground). - * Set bold mode. - * Set reverse mode and much more. - - - -Here is a sample code: -``` -#!/bin/bash - -# clear the screen -tput clear - -# Move cursor to screen location X,Y (top left is 0,0) -tput cup 3 15 - -# Set a foreground colour using ANSI escape -tput setaf 3 -echo "XYX Corp LTD." -tput sgr0 - -tput cup 5 17 -# Set reverse video mode -tput rev -echo "M A I N - M E N U" -tput sgr0 - -tput cup 7 15 -echo "1. User Management" - -tput cup 8 15 -echo "2. Service Management" - -tput cup 9 15 -echo "3. Process Management" - -tput cup 10 15 -echo "4. Backup" - -# Set bold mode -tput bold -tput cup 12 15 -read -p "Enter your choice [1-4] " choice - -tput clear -tput sgr0 -tput rc -``` - - -Sample outputs: -![Fig.03: tput in action][6] -For more detail concerning the tput command, see the following man page: -``` -man 5 terminfo -man tput -``` - -### #3: setleds Command - -The setleds command allows you to set the keyboard leds. In this example, set NumLock on: -``` -setleds -D +num -``` - -To turn it off NumLock, enter: -``` -setleds -D -num -``` - - * -caps : Clear CapsLock. - * +caps : Set CapsLock. - * -scroll : Clear ScrollLock. - * +scroll : Set ScrollLock. - - - -See setleds command man page for more information and options: -`man setleds` - -### #4: zenity Command - -The [zenity commadn will display GTK+ dialogs box][7], and return the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts. Here is a sample GUI client for the whois directory service for given domain name: - -```shell -#!/bin/bash -# Get domain name -_zenity="/usr/bin/zenity" -_out="/tmp/whois.output.$$" -domain=$(${_zenity} --title "Enter domain" \ - --entry --text "Enter the domain you would like to see whois info" ) - -if [ $? -eq 0 ] -then - # Display a progress dialog while searching whois database - whois $domain | tee >(${_zenity} --width=200 --height=100 \ - --title="whois" --progress \ - --pulsate --text="Searching domain info..." \ - --auto-kill --auto-close \ - --percentage=10) >${_out} - - # Display back output - ${_zenity} --width=800 --height=600 \ - --title "Whois info for $domain" \ - --text-info --filename="${_out}" -else - ${_zenity} --error \ - --text="No input provided" -fi -``` - -Sample outputs: -![Fig.04: zenity in Action][8] -See the zenity man page for more information and all other supports GTK+ widgets: -``` -zenity --help -man zenity -``` - -### #5: kdialog Command - -kdialog is just like zenity but it is designed for KDE desktop / qt apps. You can display dialogs using kdialog. The following will display message on screen: -``` -kdialog --dontagain myscript:nofilemsg --msgbox "File: '~/.backup/config' not found." -``` - -Sample outputs: -![Fig.05: Suppressing the display of a dialog ][9] - -See [shell scripting with KDE Dialogs][10] tutorial for more information. - -### #6: Dialog - -[Dialog is an application used in shell scripts][11] which displays text user interface widgets. It uses the curses or ncurses library. Here is a sample code: -``` -#!/bin/bash -dialog --title "Delete file" \ ---backtitle "Linux Shell Script Tutorial Example" \ ---yesno "Are you sure you want to permanently delete \"/tmp/foo.txt\"?" 7 60 - -# Get exit status -# 0 means user hit [yes] button. -# 1 means user hit [no] button. -# 255 means user hit [Esc] key. -response=$? -case $response in - 0) echo "File deleted.";; - 1) echo "File not deleted.";; - 255) echo "[ESC] key pressed.";; -esac -``` - -See the dialog man page for details: -`man dialog` - -#### A Note About Other User Interface Widgets Tools - -UNIX and Linux comes with lots of other tools to display and control apps from the command line, and shell scripts can make use of some of the KDE / Gnome / X widget set: - - * **gmessage** - a GTK-based xmessage clone. - * **xmessage** - display a message or query in a window (X-based /bin/echo) - * **whiptail** - display dialog boxes from shell scripts - * **python-dialog** - Python module for making simple Text/Console-mode user interfaces - - - -### #7: logger command - -The logger command writes entries in the system log file such as /var/log/messages. It provides a shell command interface to the syslog system log module: -``` -logger "MySQL database backup failed." -tail -f /var/log/messages -logger -t mysqld -p daemon.error "Database Server failed" -tail -f /var/log/syslog -``` - -Sample outputs: -``` -Apr 20 00:11:45 vivek-desktop kernel: [38600.515354] CPU0: Temperature/speed normal -Apr 20 00:12:20 vivek-desktop mysqld: Database Server failed -``` - -See howto [write message to a syslog / log file][12] for more information. Alternatively, you can see the logger man page for details: -`man logger` - -### #8: setterm Command - -The setterm command can set various terminal attributes. In this example, force screen to turn black in 15 minutes. Monitor standby will occur at 60 minutes: -``` -setterm -blank 15 -powersave powerdown -powerdown 60 -``` - -In this example show underlined text for xterm window: -``` -setterm -underline on; -echo "Add Your Important Message Here" -setterm -underline off -``` - -Another useful option is to turn on or off cursor: -``` -setterm -cursor off -``` - -Turn it on: -``` -setterm -cursor on -``` - -See the setterm command man page for details: -`man setterm` - -### #9: smbclient: Sending Messages To MS-Windows Workstations - -The smbclient command can talk to an SMB/CIFS server. It can send a message to selected users or all users on MS-Windows systems: -``` -smbclient -M WinXPPro </dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 open" || echo "TCP port 25 close" -``` - -You can use [bash loop and find out open ports][14] with the snippets: -``` -echo "Scanning TCP ports..." -for p in {1..1023} -do - (echo >/dev/tcp/localhost/$p) >/dev/null 2>&1 && echo "$p open" -done -``` - - -Sample outputs: -``` -Scanning TCP ports... -22 open -53 open -80 open -139 open -445 open -631 open -``` - -In this example, your bash script act as an HTTP client: -``` -#!/bin/bash -exec 3<> /dev/tcp/${1:-www.cyberciti.biz}/80 - -printf "GET / HTTP/1.0\r\n" >&3 -printf "Accept: text/html, text/plain\r\n" >&3 -printf "Accept-Language: en\r\n" >&3 -printf "User-Agent: nixCraft_BashScript v.%s\r\n" "${BASH_VERSION}" >&3 -printf "\r\n" >&3 - -while read LINE <&3 -do - # do something on $LINE - # or send $LINE to grep or awk for grabbing data - # or simply display back data with echo command - echo $LINE -done -``` - -See the bash man page for more information: -`man bash` - -### A Note About GUI Tools and Cronjob - -You need to request local display/input service using export DISPLAY=[user's machine]:0 command if you are [using cronjob][15] to call your scripts. For example, call /home/vivek/scripts/monitor.stock.sh as follows which uses zenity tool: -`@hourly DISPLAY=:0.0 /home/vivek/scripts/monitor.stock.sh` - -Have a favorite UNIX tool to spice up shell script? Share it in the comments below. - -### about the author - -The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][16], [Facebook][17], [Google+][18]. - --------------------------------------------------------------------------------- - -via: https://www.cyberciti.biz/tips/spice-up-your-unix-linux-shell-scripts.html - -作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.cyberciti.biz -[1]:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info) -[2]:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info) -[3]:https://www.cyberciti.biz/faq/rhel-centos-fedora-linux-yum-command-howto/ (See Linux/Unix yum command examples for more info) -[4]:https://www.cyberciti.biz/media/new/tips/2010/04/notify-send.png (notify-send: Shell Script Get Or Send Desktop Notifications ) -[5]:https://www.cyberciti.biz/media/new/tips/2010/04/notify-send-with-icons-timeout.png (Linux / UNIX: Display Notifications From Your Shell Scripts With notify-send) -[6]:https://www.cyberciti.biz/media/new/tips/2010/04/tput-options.png (Linux / UNIX Script Colours and Cursor Movement With tput) -[7]:https://bash.cyberciti.biz/guide/Zenity:_Shell_Scripting_with_Gnome -[8]:https://www.cyberciti.biz/media/new/tips/2010/04/zenity-outputs.png (zenity: Linux / UNIX display Dialogs Boxes From The Shell Scripts) -[9]:https://www.cyberciti.biz/media/new/tips/2010/04/KDialog.png (Kdialog: Suppressing the display of a dialog ) -[10]:http://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs -[11]:https://bash.cyberciti.biz/guide/Bash_display_dialog_boxes -[12]:https://www.cyberciti.biz/tips/howto-linux-unix-write-to-syslog.html -[13]:https://www.cyberciti.biz/tips/freebsd-sending-a-message-to-windows-workstation.html -[14]:https://www.cyberciti.biz/faq/bash-for-loop/ -[15]:https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/ -[16]:https://twitter.com/nixcraft -[17]:https://facebook.com/nixcraft -[18]:https://plus.google.com/+CybercitiBiz