LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-29-2005, 03:36 AM   #1
pcweirdo
Member
 
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
Code:
$ script_to_parse_into_html < source_file > /tmp/temp.html; mozilla /tmp/temp.html
I can use hr!
Code:
$ 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?

http://soundless-screams.net/pcwd/misc/hr
Code:
#!/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;
 
  


Reply



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 09:24 PM
i want others to understand my handy-work rblampain Programming 3 10-31-2004 01:15 AM
Very Handy,, Monitor Specification Site The Bad Penny Linux - General 3 08-12-2004 06:33 AM
Request For Comments: E-mail security site chort Linux - Security 2 02-28-2004 04:43 PM
Bash, input validation: request for comments unSpawn Programming 3 07-25-2003 08:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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