#1: notify-send Command
Creating GUI application is not just expensive task but 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.
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:
$ sudo apt-get install libnotify-bin
In this example, send simple desktop notification from the command line, enter:
notify-send "rsnapshot done :)"
Sample outputs:
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:
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:
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, 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:
#!/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:
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:
See shell scripting with KDE Dialogs tutorial for more information.
#6: Dialog
Dialog is an application used in shell scripts 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 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 <1 Message 2 ... .. EOF
OR
echo "${Message}" | smbclient -M salesguy2
See smbclient man page or read our previous post about "sending a message to Windows Workstation" with smbclient command:
man smbclient
#10: Bash Socket Programming
Under bash you can open a socket to pass some data through it. You don't have to use curl or lynx commands to just grab data from remote server. Bash comes with two special device files which can be used to open network sockets. From the bash man page:
- /dev/tcp/host/port - If host is a valid hostname or Internet address, and port is an integer port number or service name, bash attempts to open a TCP connection to the corresponding socket.
- /dev/udp/host/port - If host is a valid hostname or Internet address, and port is an integer port number or service name, bash attempts to open a UDP connection to the corresponding socket.
You can use this technquie to dermine if port is open or closed on local or remote server without using nmap or other port scanner:
# find out if TCP port 25 open or not (echo >/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 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 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
Great And Useful Article
ReplyDeleteOnline Java Training from India
Java Training Institutes in Chennai
Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
ReplyDeleteData Science Training in Chennai
Data science training in bangalore
Data science online training
Data science training in pune
Data science training in kalyan nagar
Data Science with Python training in chenni
Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
ReplyDeletejava training in chennai | java training in bangalore
java online training | java training in pune
selenium training in chennai
selenium training in bangalore
Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.
ReplyDeleteAWS Training in Bangalore | Amazon Web Services Training in Bangalore
Amazon Web Services Training in Pune | Best AWS Training in Pune
AWS Online Training | Online AWS Certification Course - Gangboard
Selenium Training in Chennai | Best Selenium Training in Chennai
Selenium Training in Bangalore | Best Selenium Training in Bangalore
Really nice experience you have. Thank you for sharing. It will surely be an experience to someone.
ReplyDeletepython training in rajajinagar
Python training in btm
Python training in usa
Hey, Wow all the posts are very informative for the people who visit this site. Good work! We also have a Website. Please feel free to visit our site. Thank you for sharing.Well written article Thank You Sharing with Us pmp training in velachery | project management certfication in chennai | project management training institute in chennai | pmp training fee | pmp certification course in chennai
ReplyDeleteSuch an interesting content I have never come across like this
ReplyDeleteselenium testing course in chennai
selenium course
selenium testing training in chennai
best selenium training center in chennai
Selenium Training in Chennai
iOS Training in Chennai
French Classes in Chennai
Big Data Training in Chennai
web designing training in chennai
KetoViante By far the oldest (and least expensive) method to improve your penis size is with the use of guide exercises. There are such a lot of differing types and variations of KetoViante products out there out there immediately. Take into accout, that the market is flooded with all forms of so-known as penis pumps, weights and saw dust tablets that promise you every thing but the kitchen sink but deliver disappointing results. In an historic ACLU victory, a judge dominated for the primary time that abstinence-solely training goes in opposition to a state legislation mandating comprehensive KetoViante training. When doing these penis enlargement strategies, it could even be extremely advisable to stay stationary the entire time. Sex is a pure part of life and it's fitting that you can find the answers to sexual shortcomings with pure substances. You must speak with the physician concerning the usage of KetoViante pill. At present at twenty five, as I have been exploring the depths of the sexual dimension I've been amazed at the wonders of what ecstatic zones Yonggang tablets natural enhancement can present. Dietary supplements are one other standard method which have been available on the market for variety of years now of the best way to increase penis dimension.
ReplyDeletehttps://www.smore.com/k3t5u-ketoviante-trial
Thanks for your great and helpful presentation I like your good service. I always appreciate your post. That is very interesting I love reading and I am always searching for informative information like this.angular 4 training in chennai | angularjs training in chennai | angularjs best training center in chennai | angularjs training in velachery |
ReplyDeleteTreasurebox is an online store in Auckland Newzealand which provide their customers all the household items, Garden sheds, pets supplies and many more items. Now
ReplyDeleteNewly Arrived shopping trolley nz of treasurebox we will share with you.
Ceme ini sangat mudah sekali di mainkan oleh siapapun dan kalanngan manapun juga dapat bermain. Karena anda tidak perlu lagi mencari startegi atau menyusun kartu anda untuk menghasilkan kombinasi kartu terbaik
ReplyDeleteasikqq
http://dewaqqq.club/
http://sumoqq.today/
interqq
pionpoker
bandar ceme terpercaya
freebet tanpa deposit
paito warna
syair sgp
Informatical article thanks for sharingTechzprime android tips and tricks
ReplyDeletethanks for sharing this information
ReplyDeleteazure training in chennai
azure training in sholinganallur
data science training in siruseri
best data science training in omr
best data science training in sholinganallur
best devops training in chennai
best devops training institute in omr
best devops training institute in sholinganallur
Everything is very interesting to learn and easy to understood. Thank you for giving information.
ReplyDeleteEthical Hacking Training in chennai
Best Training Institute in Chennai
if are intrested in hacking then download this course Download All Technical Sagar courses Free
ReplyDeleteDownload All Technical Sagar courses Free
Download All Technical Sagar courses Free
All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.Download Best Friendship quotes for your best Friends
ReplyDeleteThe article is so informative. This is more helpful for our
ReplyDeleteLearn best software testing online certification course class in chennai with placement
Best selenium testing online course training in chennai
Best online software testing training course institute in chennai with placement
Thanks for sharing.
Thanks for sharing. I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one.
ReplyDeletebest refrigerators in india
interview questions and answers for fresher
Hello, This information is very helpful and useful. Your blog is amazing.
ReplyDeleteBolly4u, 7starhd, Filmywap, 9xmovies, Moviemad, wpgroup
This is a very great post and the way you express your all post details that is too good. thanks for sharing- wpgroup , 9xMovie , TamilMV , Jio Rockers , movieswood , 9xRockers , Full Form .
ReplyDeleteclash of clans modded apk
ReplyDeleteLikes a blog sql online training
ReplyDeleteThanks Admin For That Great article. I have read that article so many time for that i have thought its beautifull article ever i have read. you may also like Kinemaster Pro Mod without Watermark Apk.
ReplyDeleteThank you for sharing such a nice post!
ReplyDeleteLearn DevOps Training from the Industry Experts we bridge the gap between the need of the industry. Softgen Infotech provide the Best DevOps Training in Bangalore with 100% Placement Assistance. Book a Free Demo Today.
these 10 Tools To Spice UNIX Shell Scripts is very useful ,thanks for sharing such a quality content ,if looking for more information related to Information Technology Engineering ,visit: Information Technology Engineering
ReplyDeleteThank you for posting such a great article! I found your website perfect for my needs. It contains wonderful and helpful posts. Keep up the good work!. Thank you for this wonderful Article! healthy diet
ReplyDeletehow to become a management consultant
ReplyDeletemanagement consulting training
how to become a management consultant
management consulting training
Thank you for sharing useful information with us. please keep sharing like this.
ReplyDeleteAnd if anyone like to take admission in Jaipur then check this
Top engineering college in Jaipur
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeletehttp://traininginmedavakkam.in/training-courses/php-training-in-medavakkam/
http://traininginmedavakkam.in/training-courses/selenium-training-in-medavakkam/
http://traininginmedavakkam.in/training-courses/big-data-training-in-medavakkam/
http://traininginmedavakkam.in/training-courses/sap-abap-training-in-medavakkam/
http://traininginmedavakkam.in/training-courses/ccnp-training-in-medavakkam/
UFC 252 Live Stream will be available for free online in the US, UK, and Germany. putlockerss.net
ReplyDeleteThe time when I had s-e-x with a random cute boy from the street. Read the full story here.
ReplyDeletenew latest technology
ReplyDeletenew latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
new latest technology
The best Natural Treatment of Atrial Fibrillation includes diet, exercise, yoga and herbs. A good nutrition is completely essential for good hearth. If you think that a petrol engine will not run on diesel fuel, it's easy to understand this idea. If you don't worry good food, then your body cannot help you as it is erected to. It lacks the necessary nutrients to function truthfully.
ReplyDeleteThanks for sharing the information. It is very useful for my future. keep sharing Fashion Designer Boutique in Mumbai
ReplyDeleteThis blog is very helpful. Thanks for sharing this type of blog with us. Really very happy to say, your post is very interesting to read. I never stop myself from saying something about it. You’re doing a great job. Keep it up and share this kind of good knowledgeable content. I have also gone through the site related to your industry that is studywec.com offers BEng (Hons) Software Engineering
ReplyDeleteInternationalization: Software Engineering and application development is by virtue an international business and therefore isn’t bound by geographical area.BEng(Hons) Software Engineering (Enroll Now)
limited seats available.
Sasche Mohr Theory
ReplyDeletePreservation of pharmaceutical products
Flow of fluid
Rheology full detailed
Thixotropy/ Measurement of Viscosity/ Instruments
Thanks for sharing valuable information . The YoWhatsApp Apk download is a modded latest version of YoWhatsApp which comes with some advanced features which are not available in official WhatsApp.
ReplyDeleteRatsms is one of the topmost leading companies that provide bulk sms services in India. They provide a trustworthy cost to bulk sms compare to others if anyone wants a bulk sms gateway please contact them for a low-cost bulk sms service.
ReplyDeleteSMS Service provider in India | bulk sms explicit Bangalore | promotional sms provider | bulk sms reseller mysuru | SMS API | bulk sms gateway
Trade FX At Home On Your PC: roboforex login Is A Forex Trading Company. The Company States That You Can Make On Average 80 – 300 Pips Per Trade. roboforex login States That It Is Simple And Easy To Get Started.
ReplyDeleteData Science Institute Inventateq offers the best data science courses in Bangalore, while also providing job placement services for all of our students to help them apply their knowledge to real-world data science problems. Inventateq data science training offers students the opportunity to learn.
ReplyDeleteinventateq.com/data-science-training-courses-bangalore.php
Nice article
ReplyDeleteInternship providing companies in chennai | Where to do internship | internship opportunities in Chennai | internship offer letter | What internship should i do | How internship works | how many internships should i do ? | internship and inplant training difference | internship guidelines for students | why internship is necessary
Bfarf stock Real-Time Overview Of A Stock, Including Recent And Historical Price Charts, News, Events, Analyst Rating Changes And Other Key Stock Information.
ReplyDeleteGet the latest Mmatf Stock quotes, news and trends at your fingertips across all of your devices, available 247. Our stock quote system helps financial professionals keep up on the latest data and locate charts to help in their own business.
ReplyDeleteNatural Treatment for Granuloma Annulare that can help manages this condition naturally. Herbal Supplement can decrease itching and the occurrence of skin lesions.
ReplyDeleteNatural Treatment for Actinic Keratosis is to prevent the lesions from turning into skin cancers. Herbal Supplement used to treat or reduce the symptoms.
ReplyDeleteNatural Remedies for Burning Mouth Syndrome Options (2013). According to his experience,
ReplyDeleteChanging your diet can have a tremendous impact on your burning mouth syndrome symptoms.One quick remedy is taking Breneton; it’s an Herbal Supplement for Burning Mouth Syndrome that’s extremely effective at treating and reducing burning mouth syndrome symptoms. how much pain and discomfort you’re experiencing and other things associated with burning mouth syndrome. Note your symptoms before taking Herbal Supplements.
One of several ways you can treat granuloma annulare is using a potent and effective Herbal Remedies for Granuloma Annulare. Herbal supplements for granuloma annulare include milk thistle, borage oil, dandelion root, red clover extract, burdock root, white willow bark, and St. John’s wort, among others. It would help if you chose a 100% natural herbal supplement that contains only pure herbs without fillers or additives.
ReplyDeleteHerbal Supplement for Emphysema Helps Boost Energy Levels: If you or a loved one is suffering from shortness of breath caused by lung diseaseNatural Treatment for Emphysema may include oregano, an herb with powerful antioxidant properties.Thyme is a Natural Remedies for Emphysema.Rosemary is used in Herbal Remedies for Emphysema to help protect healthy cells from damage, improving lung function.
ReplyDelete