If there was no Perl, I would probably to choose bash and make most of the times. Come to think of it, I am glad that Perl is around.
Entries Tagged as 'Shell'
On programming languages
Posted in All on August 8th, 2005 · No Comments
→ No CommentsTags: open_source, Perl, Personal, Programming, Shell, Thoughts
Watching over logs in KDE
Posted in All on June 19th, 2005 · No Comments
I know of a lot of people who enjoy having a terminal window with scrolling logs on their desktop. Setting one up was never a challange, but there are some nice KDE options that one could use that not so many people know about. At least I didn’t know until today.
→ No CommentsTags: Desktop, KDE, Programming, Shell, tips
Have your breaks in time with KDE
Posted in All on May 31st, 2005 · No Comments
I’ve already talked about KDialog and DCOP which are two magic KDE tools that could use more promotion. Today I came across another nice examlpe in this post.
#!/bin/bash
PROGRESS=$(kdialog --icon kalarm --title "Short rest" \
--progressbar "Take a break..." 30)
if [ $PROGRESS ]; then
for (( i=0; i<30; i++ )); do
dcop $PROGRESS setProgress $i
sleep 1
done
dcop $PROGRESS close
fi
This simple shell script will remind you to have timed 30 second breaks when executed at predefined intervals from KAlarm. You’ll see a nice progress bar while having a break.
→ No CommentsTags: Computers, Desktop, KDE, Programming, Shell
Handling arguments with spaces in bash
Posted in All on May 27th, 2005 · 3 Comments
Way to often I get it wrong, so I decided to right this down…
When processing the list of arguments in your bash script, remember that often arguments such as file names contain spaces. The wrong way to go about this is:
#!/bin/bash for FILE in $* do echo "$FILE" done
The right way to do it is:
#!/bin/bash for FILE in "$@" do echo "$FILE" done
Advanced Bash-Scripting Guide explains the difference in “Internal Variables” chapter.
→ 3 CommentsTags: Computers, Programming, Shell
Reminder about NTP
Posted in All on May 24th, 2005 · No Comments
NTP - Network Time Protocol allows for automatic and precise time synchronization over the network. There are many problems that can be caused by incorrect time - starting from logs confusions and going to software locks due to file timestamps. Configuring NTP is very easy. Just install the ntp RPM that comes with Red Hat or Fedora Linux (or a number of other Linux distributions) and use one of the two modes described below.
- Full blown NTP server. In this mode, you’ll have to edit
/etc/ntp.confto specify a number of NTP servers to synchronize time from, as well as a lit of machines that can synchronize time with your server. Usually you’d want to have only one full blown NTP servers per network. - Simple NTP client. This is even easier to configure than the previous mode. All you have to do is add these two commands to your scheduler (cron or similar) to execute hourly.
/usr/sbin/ntpdate -s ntp_server_ip_or_hostname /sbin/hwclock -w
While modern computers are very smart and fast, they don’t have any special skills at keeping the time precisely correct. Internal timers get offset by power cuts, CPU usage bursts, and things like that. The daily changes are small, but when left unattended for a longer period of times, clocks can run ahead or stay back for as long as days!
Here is a log record from one of the servers in our office:
21:01:01 ... ntpdate[...]: ... offset 0.250427 sec 22:01:00 ... ntpdate[...]: ... offset 0.251682 sec 23:01:01 ... ntpdate[...]: ... offset 0.251269 sec 00:01:01 ... ntpdate[...]: ... offset 0.251013 sec 01:01:01 ... ntpdate[...]: ... offset 0.250451 sec 02:01:01 ... ntpdate[...]: ... offset 0.250061 sec 03:01:01 ... ntpdate[...]: ... offset 0.250239 sec 04:01:01 ... ntpdate[...]: ... offset 0.250313 sec 05:01:00 ... ntpdate[...]: ... offset 0.250112 sec 06:01:01 ... ntpdate[...]: ... offset 0.250554 sec 07:01:01 ... ntpdate[...]: ... offset 0.250691 sec 08:01:01 ... ntpdate[...]: ... offset 0.249850 sec 09:01:01 ... ntpdate[...]: ... offset 0.250418 sec 10:01:01 ... ntpdate[...]: ... offset 0.250070 sec 11:01:01 ... ntpdate[...]: ... offset 0.250488 sec
As you can see, this machine’s time inconsistencies are as large as quarter of a second per hour, which can result in 6 seconds per day (24 hours). This alone can cause noticable slowdowns in software that counts on time being always correct.
P.S.: There are NTP implementations for other operating systems as well. Google is your friend.
→ No CommentsTags: Computers, Linux, Operating_Systems, Shell