{"id":119390,"date":"2018-09-11T08:26:58","date_gmt":"2018-09-11T00:26:58","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=119390"},"modified":"2018-09-04T10:45:43","modified_gmt":"2018-09-04T02:45:43","slug":"linux-shell-tools","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-shell-tools.html","title":{"rendered":"\u51e0\u4e2a\u589e\u52a0 linux shell \u811a\u672c\u8da3\u5473\u7684\u5de5\u5177"},"content":{"rendered":"
\u6709\u4e9b\u8bef\u89e3\u8ba4\u4e3a shell \u811a\u672c\u4ec5\u7528\u4e8e CLI \u73af\u5883\u3002\u5b9e\u9645\u4e0a\u5728 KDE \u6216 Gnome \u684c\u9762\u4e0b\uff0c\u4f60\u53ef\u4ee5\u6709\u6548\u7684\u4f7f\u7528\u5404\u79cd\u5de5\u5177\u7f16\u5199 GUI \u6216\u8005\u7f51\u7edc\uff08socket\uff09\u811a\u672c\u3002shell \u811a\u672c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b GUI \u7ec4\u4ef6\uff08\u83dc\u5355\u3001\u8b66\u544a\u6846\u3001\u8fdb\u5ea6\u6761\u7b49\uff09\uff0c\u4f60\u53ef\u4ee5\u63a7\u5236\u7ec8\u7aef\u8f93\u51fa\u3001\u5149\u6807\u4f4d\u7f6e\u4ee5\u53ca\u5404\u79cd\u8f93\u51fa\u6548\u679c\u7b49\u7b49\u3002\u5229\u7528\u4e0b\u9762\u7684\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u6784\u5efa\u5f3a\u58ee\u7684\u3001\u53ef\u4ea4\u4e92\u7684\u3001\u5bf9\u7528\u6237\u53cb\u597d\u7684 UNIX\/Linux bash \u811a\u672c\u3002<\/p>\n
\u5236\u4f5c GUI \u5e94\u7528\u4e0d\u662f\u4e00\u9879\u56f0\u96be\u7684\u4efb\u52a1\uff0c\u4f46\u9700\u8981\u65f6\u95f4\u548c\u8010\u5fc3\u3002\u5e78\u8fd0\u7684\u662f\uff0cUNIX \u548c Linux \u90fd\u5e26\u6709\u5927\u91cf\u7f16\u5199\u6f02\u4eae GUI \u811a\u672c\u7684\u5de5\u5177\u3002\u4ee5\u4e0b\u5de5\u5177\u662f\u57fa\u4e8e FreeBSD \u548c Linux \u64cd\u4f5c\u7cfb\u7edf\u505a\u7684\u6d4b\u8bd5\uff0c\u800c\u4e14\u4e5f\u9002\u7528\u4e8e\u5176\u4ed6\u7c7b UNIX \u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n
notify-send<\/span> \u547d\u4ee4\u5141\u8bb8\u4f60\u501f\u52a9\u901a\u77e5\u5b88\u62a4\u8fdb\u7a0b\u53d1\u9001\u684c\u9762\u901a\u77e5\u7ed9\u7528\u6237\u3002\u8fd9\u79cd\u907f\u514d\u6253\u6270\u7528\u6237\u7684\u65b9\u5f0f\uff0c\u5bf9\u4e8e\u901a\u77e5\u684c\u9762\u7528\u6237\u4e00\u4e2a\u4e8b\u4ef6\u6216\u663e\u793a\u4e00\u4e9b\u4fe1\u606f\u662f\u6709\u7528\u7684\u3002\u5728 Debian \u6216 Ubuntu \u4e0a\uff0c\u4f60\u9700\u8981\u4f7f\u7528 apt \u547d\u4ee4<\/a>[1]<\/span> \u6216 apt-get \u547d\u4ee4<\/a>[2]<\/span> \u5b89\u88c5\u7684\u5305\uff1a<\/p>\n CentOS\/RHEL \u7528\u6237\u4f7f\u7528\u4e0b\u9762\u7684 yum \u547d\u4ee4<\/a>[3]<\/span>\uff1a<\/p>\n Fedora Linux \u7528\u6237\u4f7f\u7528\u4e0b\u9762\u7684 dnf \u547d\u4ee4\uff1a<\/p>\n \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n <\/p>\n notify-send: Shell Script Get Or Send Desktop Notifications<\/em><\/p>\n \u4e0b\u9762\u662f\u53e6\u4e00\u4e2a\u9644\u52a0\u9009\u9879\u7684\u4ee3\u7801\uff1a<\/p>\n \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n <\/p>\n Linux \/ UNIX: Display Notifications From Your Shell Scripts With notify-send<\/em><\/p>\n \u8fd9\u91cc\uff1a<\/p>\n \u5173\u4e8e\u66f4\u591a\u4f7f\u7528 notify-send<\/span> \u529f\u80fd\u7684\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003 man \u624b\u518c\u3002\u5728\u547d\u4ee4\u884c\u4e0b\u8f93\u5165 man notify-send<\/span> \u5373\u53ef\u770b\u89c1\uff1a<\/p>\n tput<\/span> \u547d\u4ee4\u7528\u4e8e\u8bbe\u7f6e\u7ec8\u7aef\u7279\u6027\u3002\u901a\u8fc7 tput<\/span> \u4f60\u53ef\u4ee5\u8bbe\u7f6e\uff1a<\/p>\n \u4e0b\u9762\u6709\u4e00\u6bb5\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n <\/p>\n Linux \/ UNIX Script Colours and Cursor Movement With tput<\/em><\/p>\n \u5173\u4e8e tput<\/span> \u547d\u4ee4\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u53c2\u89c1\u624b\u518c\uff1a<\/p>\n setleds<\/span> \u547d\u4ee4\u5141\u8bb8\u4f60\u8bbe\u7f6e\u952e\u76d8\u706f\u3002\u4e0b\u9762\u662f\u6253\u5f00\u6570\u5b57\u952e\u706f\u7684\u793a\u4f8b\uff1a<\/p>\n \u5173\u95ed\u6570\u5b57\u952e\u706f\uff0c\u8f93\u5165\uff1a<\/p>\n \u67e5\u770b setleds<\/span> \u624b\u518c\u53ef\u770b\u89c1\u66f4\u591a\u4fe1\u606f\u548c\u9009\u9879 man setleds<\/span>\u3002<\/p>\n zenity \u547d\u4ee4\u663e\u793a GTK+ \u5bf9\u8bdd\u6846<\/a>[4]<\/span>\uff0c\u5e76\u4e14\u8fd4\u56de\u7528\u6237\u8f93\u5165\u3002\u5b83\u5141\u8bb8\u4f60\u4f7f\u7528\u5404\u79cd Shell \u811a\u672c\u5411\u7528\u6237\u5c55\u793a\u6216\u8bf7\u6c42\u4fe1\u606f\u3002\u4e0b\u9762\u662f\u4e00\u4e2a whois<\/span> \u6307\u5b9a\u57df\u540d\u76ee\u5f55\u670d\u52a1\u7684 GUI \u5ba2\u6237\u7aef\u793a\u4f8b\u3002<\/p>\n \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n <\/p>\n zenity: Linux \/ UNIX display Dialogs Boxes From The Shell Scripts<\/em><\/p>\n \u53c2\u89c1\u624b\u518c\u83b7\u53d6\u66f4\u591a zenity<\/span> \u4fe1\u606f\u4ee5\u53ca\u5176\u4ed6\u652f\u6301 GTK+ \u7684\u7ec4\u4ef6\uff1a<\/p>\n kdialog<\/span> \u547d\u4ee4\u4e0e zenity<\/span> \u7c7b\u4f3c\uff0c\u4f46\u5b83\u662f\u4e3a KDE \u684c\u9762\u548c QT \u5e94\u7528\u8bbe\u8ba1\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 kdialog<\/span> \u5c55\u793a\u5bf9\u8bdd\u6846\u3002\u4e0b\u9762\u793a\u4f8b\u5c06\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u4fe1\u606f\uff1a<\/p>\n \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n <\/p>\n Kdialog: Suppressing the display of a dialog<\/em><\/p>\n \u53c2\u89c1 \u300aKDE \u5bf9\u8bdd\u6846 Shell \u811a\u672c\u7f16\u7a0b<\/a>[5]<\/span>\u300b \u6559\u7a0b\u83b7\u53d6\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n Dialog \u662f\u4e00\u4e2a\u4f7f\u7528 Shell \u811a\u672c\u7684\u5e94\u7528<\/a>[6]<\/span>\uff0c\u663e\u793a\u7528\u6237\u754c\u9762\u7ec4\u4ef6\u7684\u6587\u672c\u3002\u5b83\u4f7f\u7528 curses \u6216\u8005 ncurses \u5e93\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n \u53c2\u89c1 dialog<\/span> \u624b\u518c\u83b7\u53d6\u8be6\u7ec6\u4fe1\u606f\uff1aman dialog<\/span>\u3002<\/p>\n UNIX\u3001Linux \u63d0\u4f9b\u4e86\u5927\u91cf\u5176\u4ed6\u5de5\u5177\u6765\u663e\u793a\u548c\u63a7\u5236\u547d\u4ee4\u884c\u4e2d\u7684\u5e94\u7528\u7a0b\u5e8f\uff0cshell \u811a\u672c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b KDE\u3001Gnome\u3001X \u7ec4\u4ef6\u96c6\uff1a<\/p>\n logger<\/span> \u547d\u4ee4\u5c06\u4fe1\u606f\u5199\u5230\u7cfb\u7edf\u65e5\u5fd7\u6587\u4ef6\uff0c\u5982\uff1a\/var\/log\/messages<\/span>\u3002\u5b83\u4e3a\u7cfb\u7edf\u65e5\u5fd7\u6a21\u5757 syslog \u63d0\u4f9b\u4e86\u4e00\u4e2a shell \u547d\u4ee4\u884c\u63a5\u53e3\uff1a<\/p>\n \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n \u53c2\u89c1 \u300a\u5982\u4f55\u5199\u6d88\u606f\u5230 syslog \u6216 \u65e5\u5fd7\u6587\u4ef6<\/a>[7]<\/span>\u300b \u83b7\u5f97\u66f4\u591a\u4fe1\u606f\u3002\u6b64\u5916\uff0c\u4f60\u4e5f\u53ef\u4ee5\u67e5\u770b logger \u624b\u518c\u83b7\u53d6\u8be6\u7ec6\u4fe1\u606f\uff1aman logger<\/span><\/p>\n setterm<\/span> \u547d\u4ee4\u53ef\u8bbe\u7f6e\u4e0d\u540c\u7684\u7ec8\u7aef\u5c5e\u6027\u3002\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4f1a\u5f3a\u5236\u5c4f\u5e55\u5728 15 \u5206\u949f\u540e\u53d8\u9ed1\uff0c\u76d1\u89c6\u5668\u5219 60 \u5206\u949f\u540e\u5f85\u673a\u3002<\/p>\n \u4e0b\u9762\u7684\u4f8b\u5b50\u5c06 xterm \u7a97\u53e3\u4e2d\u7684\u6587\u672c\u4ee5\u4e0b\u5212\u7ebf\u5c55\u793a\uff1a<\/p>\n \u53e6\u4e00\u4e2a\u6709\u7528\u7684\u9009\u9879\u662f\u6253\u5f00\u6216\u5173\u95ed\u5149\u6807\u663e\u793a\uff1a<\/p>\n \u6253\u5f00\u5149\u6807\uff1a<\/p>\n \u53c2\u89c1 setterm \u547d\u4ee4\u624b\u518c\u83b7\u53d6\u8be6\u7ec6\u4fe1\u606f\uff1aman setterm<\/span><\/p>\n smbclient<\/span> \u547d\u4ee4\u53ef\u4ee5\u4e0e SMB\/CIFS \u670d\u52a1\u5668\u901a\u8baf\u3002\u5b83\u53ef\u4ee5\u5411 MS-Windows \u7cfb\u7edf\u4e0a\u9009\u5b9a\u6216\u5168\u90e8\u7528\u6237\u53d1\u9001\u6d88\u606f\u3002<\/p>\n \u6216<\/p>\n \u53c2\u89c1 smbclient<\/span> \u624b\u518c\u6216\u8005\u9605\u8bfb\u6211\u4eec\u4e4b\u524d\u53d1\u5e03\u7684\u6587\u7ae0\uff1a\u300a\u7ed9 Windows \u5de5\u4f5c\u7ad9\u53d1\u9001\u6d88\u606f<\/a>[8]<\/span>\u300b\uff1aman smbclient<\/span><\/p>\n \u5728 bash \u4e0b\uff0c\u4f60\u53ef\u4ee5\u6253\u5f00\u4e00\u4e2a\u5957\u63a5\u5b57\u5e76\u901a\u8fc7\u5b83\u53d1\u9001\u6570\u636e\u3002\u4f60\u4e0d\u5fc5\u4f7f\u7528 curl<\/span> \u6216\u8005 lynx<\/span> \u547d\u4ee4\u6293\u53d6\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u6570\u636e\u3002bash \u548c\u4e24\u4e2a\u7279\u6b8a\u7684\u8bbe\u5907\u6587\u4ef6\u53ef\u7528\u4e8e\u6253\u5f00\u7f51\u7edc\u5957\u63a5\u5b57\u3002\u4ee5\u4e0b\u9009\u81ea bash \u624b\u518c\uff1a<\/p>\n \u4f60\u53ef\u4ee5\u4f7f\u7528\u8fd9\u9879\u6280\u672f\u6765\u786e\u5b9a\u672c\u5730\u6216\u8fdc\u7a0b\u670d\u52a1\u5668\u7aef\u53e3\u662f\u6253\u5f00\u6216\u8005\u5173\u95ed\u72b6\u6001\uff0c\u800c\u65e0\u9700\u4f7f\u7528 nmap<\/span> \u6216\u8005\u5176\u5b83\u7684\u7aef\u53e3\u626b\u63cf\u5668\u3002<\/p>\n \u4e0b\u9762\u7684\u4ee3\u7801\u7247\u6bb5\uff0c\u4f60\u53ef\u4ee5\u5229\u7528 bash \u5faa\u73af\u627e\u51fa\u5df2\u6253\u5f00\u7684\u7aef\u53e3<\/a>[9]<\/span>\uff1a<\/p>\n \u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n \u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u4f60\u7684 bash \u811a\u672c\u5c06\u50cf HTTP \u5ba2\u6237\u7aef\u4e00\u6837\u5de5\u4f5c\uff1a<\/p>\n \u53c2\u89c1 bash \u624b\u518c\u83b7\u53d6\u66f4\u591a\u4fe1\u606f\uff1aman bash<\/span><\/p>\n \u5982\u679c\u4f60 \u4f7f\u7528 crontab<\/a>[10]<\/span> \u6765\u542f\u52a8\u4f60\u7684\u811a\u672c\uff0c\u4f60\u9700\u8981\u4f7f\u7528 export DISPLAY=[\u7528\u6237\u673a\u5668]:0<\/span> \u547d\u4ee4\u8bf7\u6c42\u672c\u5730\u663e\u793a\u6216\u8f93\u51fa\u670d\u52a1\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u4f7f\u7528 zenity<\/span> \u5de5\u5177\u8c03\u7528 \/home\/vivek\/scripts\/monitor.stock.sh<\/span>\uff1a<\/p>\n \u4f60\u6709\u559c\u6b22\u7684\u53ef\u4ee5\u589e\u52a0 shell \u811a\u672c\u8da3\u5473\u7684 UNIX \u5de5\u5177\u4e48\uff1f\u8bf7\u5728\u4e0b\u9762\u7684\u8bc4\u8bba\u533a\u5206\u4eab\u5b83\u5427\u3002<\/p>\n \u672c\u6587\u4f5c\u8005\u662f nixCraft \u521b\u59cb\u4eba\u3001\u4e00\u4e2a\u8001\u7ec3\u7684\u7cfb\u7edf\u7ba1\u7406\u5458\u3001Linux \u64cd\u4f5c\u7cfb\u7edf\u548c UNIX shell \u7f16\u7a0b\u57f9\u8bad\u5e08\u3002\u4ed6\u670d\u52a1\u6765\u81ea\u5168\u7403\u7684\u5ba2\u6237\u548c\u4e0d\u540c\u7684\u884c\u4e1a\uff0c\u5305\u62ec IT \u3001\u6559\u80b2\u3001\u9632\u52a1\u548c\u7a7a\u95f4\u63a2\u7d22\u3001\u8fd8\u6709\u975e\u8425\u5229\u7ec4\u7ec7\u3002\u4f60\u53ef\u4ee5\u5728 Twitter<\/a>[11]<\/span>\uff0cFacebook<\/a>[12]<\/span>\uff0cGoogle+<\/a>[13]<\/span> \u4e0a\u9762\u5173\u6ce8\u4ed6\u3002<\/p>\n via: https:\/\/www.cyberciti.biz\/tips\/spice-up-your-unix-linux-shell-scripts.html<\/a><\/p>\n \u4f5c\u8005\uff1aVivek Gite<\/a>[14]<\/span> \u8bd1\u8005\uff1apygmalion666<\/a>[15]<\/span> \u6821\u5bf9\uff1awxy<\/a>[16]<\/span><\/p>\n \u672c\u6587\u7531 LCTT<\/a>[17]<\/span> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a>[18]<\/span> \u8363\u8a89\u63a8\u51fa<\/p>\n \u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-9510-1.html<\/a><\/p>\nsudo apt-get install libnotify-bin\r\n<\/pre>\n
sudo yum install libnotify\r\n<\/pre>\n
`$ sudo dnf install libnotify`\r\nIn this example, send simple desktop notification from the command line, enter:\r\n### \u53d1\u9001\u4e00\u4e9b\u901a\u77e5 ###\r\nnotify-send \"rsnapshot done :)\"\r\n<\/pre>\n
...\r\nalert=18000\r\nlive=$(lynx --dump http:\/\/money.rediff.com\/ | grep 'BSE LIVE' | awk '{ print $5}' | sed 's\/,\/\/g;s\/\\.[0-9]*\/\/g')\r\n[ $notify_counter -eq 0 ] && [ $live -ge $alert ] && { notify-send -t 5000 -u low -i \"BSE Sensex touched 18k\"; notify_counter=1; }\r\n...\r\n<\/pre>\n
\n
man notify-send\r\n<\/pre>\n
\n
#!\/bin\/bash\r\n\r\n# clear the screen\r\ntput clear\r\n\r\n# Move cursor to screen location X,Y (top left is 0,0)\r\ntput cup 3 15\r\n\r\n# Set a foreground colour using ANSI escape\r\ntput setaf 3\r\necho \"XYX Corp LTD.\"\r\ntput sgr0\r\n\r\ntput cup 5 17\r\n# Set reverse video mode\r\ntput rev\r\necho \"M A I N - M E N U\"\r\ntput sgr0\r\n\r\ntput cup 7 15\r\necho \"1. User Management\"\r\n\r\ntput cup 8 15\r\necho \"2. Service Management\"\r\n\r\ntput cup 9 15\r\necho \"3. Process Management\"\r\n\r\ntput cup 10 15\r\necho \"4. Backup\"\r\n\r\n# Set bold mode\r\ntput bold\r\ntput cup 12 15\r\nread -p \"Enter your choice [1-4] \" choice\r\n\r\ntput clear\r\ntput sgr0\r\ntput rc\r\n<\/pre>\n
man 5 terminfo\r\nman tput\r\n<\/pre>\n
setleds -D +num\r\n<\/pre>\n
setleds -D -num\r\n<\/pre>\n
\n
#!\/bin\/bash\r\n# Get domain name\r\n_zenity=\"\/usr\/bin\/zenity\"\r\n_out=\"\/tmp\/whois.output.$$\"\r\ndomain=$(${_zenity} --title \"Enter domain\" \\\r\n --entry --text \"Enter the domain you would like to see whois info\" )\r\n\r\nif [ $? -eq 0 ]\r\nthen\r\n # Display a progress dialog while searching whois database\r\n whois $domain | tee >(${_zenity} --width=200 --height=100 \\\r\n --title=\"whois\" --progress \\\r\n --pulsate --text=\"Searching domain info...\" \\\r\n --auto-kill --auto-close \\\r\n --percentage=10) >${_out}\r\n\r\n # Display back output\r\n ${_zenity} --width=800 --height=600 \\\r\n --title \"Whois info for $domain\" \\\r\n --text-info --filename=\"${_out}\"\r\nelse\r\n ${_zenity} --error \\\r\n --text=\"No input provided\"\r\nfi\r\n<\/pre>\n
zenity --help\r\nman zenity\r\n<\/pre>\n
kdialog --dontagain myscript:nofilemsg --msgbox \"File: '~\/.backup\/config' not found.\"\r\n<\/pre>\n
#!\/bin\/bash\r\ndialog --title \"Delete file\" \\\r\n--backtitle \"Linux Shell Script Tutorial Example\" \\\r\n--yesno \"Are you sure you want to permanently delete \\\"\/tmp\/foo.txt\\\"?\" 7 60\r\n\r\n# Get exit status\r\n# 0 means user hit [yes] button.\r\n# 1 means user hit [no] button.\r\n# 255 means user hit [Esc] key.\r\nresponse=$?\r\ncase $response in\r\n 0) echo \"File deleted.\";;\r\n 1) echo \"File not deleted.\";;\r\n 255) echo \"[ESC] key pressed.\";;\r\nesac\r\n<\/pre>\n
\n
logger \"MySQL database backup failed.\"\r\ntail -f \/var\/log\/messages\r\nlogger -t mysqld -p daemon.error \"Database Server failed\"\r\ntail -f \/var\/log\/syslog\r\n<\/pre>\n
Apr 20 00:11:45 vivek-desktop kernel: [38600.515354] CPU0: Temperature\/speed normal\r\nApr 20 00:12:20 vivek-desktop mysqld: Database Server failed\r\n<\/pre>\n
setterm -blank 15 -powersave powerdown -powerdown 60\r\n<\/pre>\n
setterm -underline on;\r\necho \"Add Your Important Message Here\"\r\nsetterm -underline off\r\n<\/pre>\n
setterm -cursor off\r\n<\/pre>\n
setterm -cursor on\r\n<\/pre>\n
smbclient -M WinXPPro <<eof\r\nMessage 1\r\nMessage 2\r\n...\r\n..\r\nEOF\r\n<\/pre>\n
echo \"${Message}\" | smbclient -M salesguy2\r\n<\/pre>\n
\n
# find out if TCP port 25 open or not\r\n(echo >\/dev\/tcp\/localhost\/25) &>\/dev\/null && echo \"TCP port 25 open\" || echo \"TCP port 25 close\"\r\n<\/pre>\n
echo \"Scanning TCP ports...\"\r\nfor p in {1..1023}\r\ndo\r\n (echo >\/dev\/tcp\/localhost\/$p) >\/dev\/null 2>&1 && echo \"$p open\"\r\ndone\r\n<\/pre>\n
Scanning TCP ports...\r\n22 open\r\n53 open\r\n80 open\r\n139 open\r\n445 open\r\n631 open\r\n<\/pre>\n
#!\/bin\/bash\r\nexec 3<> \/dev\/tcp\/${1:-www.cyberciti.biz}\/80\r\n\r\nprintf \"GET \/ HTTP\/1.0\\r\\n\" >&3\r\nprintf \"Accept: text\/html, text\/plain\\r\\n\" >&3\r\nprintf \"Accept-Language: en\\r\\n\" >&3\r\nprintf \"User-Agent: nixCraft_BashScript v.%s\\r\\n\" \"${BASH_VERSION}\" >&3\r\nprintf \"\\r\\n\" >&3\r\n\r\nwhile read LINE <&3\r\ndo\r\n # do something on $LINE\r\n # or send $LINE to grep or awk for grabbing data\r\n # or simply display back data with echo command\r\n echo $LINE\r\ndone\r\n<\/pre>\n
@hourly DISPLAY=:0.0 \/home\/vivek\/scripts\/monitor.stock.sh\r\n<\/pre>\n
\n\n