Monday, June 30, 2008

FTP Using a One-Liner and Perl Script

A colleague of mine, Mahlon Anderson, wanted to revisit the FTP Using a Shell Script post.

Here is what he had to say...

Here is a creative way to put an FTP command on a single line. Why one line? The short story is I needed to do an ftp in a crontab without calling another script.

Three things to note:

1) I have only tested this with Solaris 8.
2) This works in the one true shell, Bourne shell.
3) If you have a "$" in your password, it might cause you problems.

Use this in a Perl script. (I didn’t have access to the CPAN FTP module)

# vi


$USER = “esoft”;
$echo = ‘echo “quote user ‘ . $USER. ‘\nquote pass ‘ . $PASSWORD .’\nbin\nlcd ‘ . $DIR . ‘\nmput $FILE\n”’;
@status = ‘$echo| ftp –nv $REMOTE‘;
print @status;

The FTP module is for doing FTP directly with Perl...basically system calls to the C library directly. With the right modules, you can do all that from Perl without having to resort to the back quotes.

Run via CLI

# ./

Sunday, June 29, 2008

Show HTML Tags Within a Blogger Post

Previously, I was having issues displaying HTML tags within a Blogger post. To get around that pesky issue, I used an underscore, e.g. <_head>,<_title>, <_file>, etc, or generated a jpg image of the example to demonstrate the use of a particular tag. But this action made it inconvenient to simply cut and paste without the arduous task of retyping or modification. Now I am using the textarea tag and it seems to be working fine with the Blogger platform.

Note: If you get the following error message when publishing/saving: "Your HTML cannot be accepted: Tag is not allowed: <_whatever_tag>", check the box to ignore.

Here is an example run that is followed by the parameters used for the textarea.

Wednesday, June 25, 2008

An Enhanced and More Powerful Syslog App - syslog-ng

We recently purchased a new network application/appliance.

As part of my normal practice, I wanted to configure the
appliance to duplicate its logs to our centralized syslog server.
With standard syslogd, you add one line to your configuration
file (syslog.conf) and restart the daemon.

But this appliance uses syslog-ng, an enhanced and more
powerful syslog application.

The syslog-ng configuration file (syslog-ng.conf) includes
four main components: source, filter, destination, and log.

1. source (required) - This tells syslog-ng the source of
the log data. This could be a network port, streams,
a file (/proc/kmsg).

2. filter (optional) - If you want to throw all your log
data into one file, you don't need a filter.

3. destination (required) - Syslog-ng needs to know what
to do with the data it reads from "source". Destination
can be a file, a remote server IP, a pipe, usertty, etc.

4. log (required) - This is the line that makes it all
happen by bringing the above items together.

This line basically says:
"look at all the logs coming from $source, pull
this $filter and save it in $destination."

NOTE: You can include multiple source, filter and
destination on this line.

For example:
I want to configure syslog-ng to send all logs to a
local file and to my Centralized Log Server (IP

# Solaris Configuration:

# This source entry allows locally generated logs to be captured

source local { sun-streams("/dev/log" door("/etc/.syslog_door")); internal(); };

# FILTER (optional)
# I'm not defining any filter since I want everything.

# I want to send the logs via standard syslog udp port to IP#
# and to a file locally, /var/log/everything.log.

destination logserver { udp(""); };
destination localfile { file("/var/log/everything.log"); };


log { source(local); destination(logserver); destination(localfile); };


After you edit your configuration file, you can verify the syntax using this command:

$ syslog-ng -s

If you don't have any errors, restart your syslog-ng daemon.
You should now be logging everything to the file /var/log/everything.log as well as to the remote log server.

Post provided by Mary M. Chaddock

Sunday, June 15, 2008 - NOT an Official Google Shell

After reviewing my statistics today, I found a couple referrals from this website, At first, I did not think much of its Spartan appearance (like I have room to talk). But after tinkering with it awhile, I realized it was pretty darn functional. As you can see below, it behaves similar to a UNIX shell.

By the way, the author of the utility states this is NOT an official Google product! As usual, here is an example run.

Goosh 0.4.4-beta #1 Tue, 03 Jun 08 22:59:00 UTC Google/Ajax

Welcome to - the unofficial google shell.

This google-interface behaves similar to a unix-shell.
You type commands and the results are shown on this page.

goosh is powered by google.

goosh is written by Stefan Grothkopp (email address deleted)
it is NOT an official google product!

Your language has been set to: en (use lang to change it)
Enter help or h for a list of commands.>> help


command aliases parameters function
web (search,s,w) [keywords] google web search
lucky (l) [keywords] go directly to first result
images (image,i) [keywords] google image search
wiki (wikipedia) [keywords] wikipedia search
clear (c) clear the screen
help (man,h,?) [command] displays help text
news (n) [keywords] google news search
blogs (blog,b) [keywords] google blog search
feeds (feed,f) [keywords] google feed search
open (o) open url in new window
go (g) open url
more (m) get more results
in (site) search in a specific website
load load an extension
video (videos,v) [keywords] google video search
read (rss,r) read feed of url
place (places,map,p) [address] google maps search
lang change language
addengine add goosh to firefox search box
translate (trans,t) [lang1] [lang2] google translation
ls [command] lists commands
cd change mode

- Enter green commands without parameters to change default mode.
- Anything that's not a command will search in current default mode.
- Aliases will expand to commands. Numbers will expand to corresponding search results.
- Use cursor up and down for command history.
- Enter keyword and hit the tab-key for tab-completion.> translate english spanish Father's Day
translating "Father's Day" from "english" to "spanish":

"Día del Padre"> t english german Father's Day
translating "Father's Day" from "english" to "german":


Wednesday, June 11, 2008

Configure Power Management with power.conf

I had a few (actually more than a few) in-house complaints regarding my personal workstation’s uptime schedule. The complaints were legitimate since the box goes largely unused. With today’s ($137/barrel) spiraling energy costs, I can understand the concern. So to quell the incessant complaints, I decided to better manage its power consumption - modified the /etc/power.conf file.

Here is an example.
# more /etc/power.conf
autopm default
# Auto-Shutdown Idle(min) Start/Finish(hh:mm) Behavior
autoshutdown 30 9:00 9:00 noshutdown
statefile /export/home/.CPR

Changed to: After 20 minutes of non-use, shutdown.
# vi /etc/power.conf
autopm default
# Auto-Shutdown Idle(min) Start/Finish(hh:mm) Behavior
autoshutdown 20 0:00 0:00 shutdown
statefile /export/home/.CPR

Let power management know of the change
# /usr/sbin/pmconfig

Tuesday, June 03, 2008

General Purpose Debugger for Core File Analysis

One of my co-workers had an early morning interview for a Principal Systems Administration position. Per the job description, he thought the position dealt mostly with Windows-based systems and a little UNIX. But after chatting with him post-interview, it was apparent that it was the latter. He seemed a bit shell-shocked. Why? He said the much younger interviewer had a plethora of detailed questions related to UNIX commands. I don't think he prepared as well for the UNIX side as he did for the Windows side. Unfortunately, he was only given a couple days to prepare.

Here is one of several commands he kept asking me about.

What UNIX command do you use when you want to perform analysis on a core file?

Here are a couple examples of the general purpose debugger, adb.

# adb /apps/myapps/bin/myexecutable /apps/myapps/bin/core
# adb -k vmunix.n vmcore.n

Core files generate a lot of lines and you might be able to extract some of text-based lines with the strings commands.
# strings core | grep -i pattern

Search for other debuggers and then consult the man pages
# catman -w (if you don't have a windex)
# man -k debugger

By the way, Sun has a script,, to read core files via SunSolve.
# $HOME/ vmunix.n vmcore.n