Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-29-2005, 04:36 AM   #1
Registered: Oct 2004
Location: Melbourne-ish, Australia
Distribution: Gentoo, Windows XP Pro
Posts: 58

Rep: Reputation: 15
Handy Runner - Request For Comments

G'day all,

I wrote this script, called hr for now.

The idea behind this script is to add infinite preprocessing abilities to programs which have none. For example, I might have a script for parsing some source file into html code, and I want to view that in mozilla. Rather than
$ script_to_parse_into_html < source_file > /tmp/temp.html; mozilla /tmp/temp.html
I can use hr!
$ mozilla `hr 'script_to_parse_into_html < source_file'`
This might seem stupid, but for me, it means less typing each time. Plus, I don't have to be creative thinking of a temporary file that doesn't already exist each time.

This is a Request For Comments. Do you think this concept is stupid? Do you like it? How could the perl script be improved?
#!/usr/bin/perl -w

# This script passes its arguments to a shell, saving
# the output to a temporary file. This script then 
# prints the name of that temporary file to stdout.

# Make temp directory if not already there.
my $tmpdir = '/tmp/hr';
if (!(-d $tmpdir)) {
        mkdir $tmpdir;

my $outfile = `mktemp $tmpdir/.XXXXXX`;

my $ret;
if (!($ret = system(join(' ', @ARGV, " > $outfile")))) {
        print $outfile;
} else {
        print STDERR "hr: Error running given command! $ret";
        exit 1;
exit 0;


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comments request for "O'Reilly's Linux iptables Pocket Reference" carboncopy General 3 03-03-2005 10:24 PM
i want others to understand my handy-work rblampain Programming 3 10-31-2004 02:15 AM
Very Handy,, Monitor Specification Site The Bad Penny Linux - General 3 08-12-2004 07:33 AM
Request For Comments: E-mail security site chort Linux - Security 2 02-28-2004 05:43 PM
Bash, input validation: request for comments unSpawn Programming 3 07-25-2003 09:03 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:12 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration