Uploading bash output within IRSSI

I’m hardly an IRSSI power-user, but I occasionally make use of its more advanced features. While IRSSI already allows shell execution, it’s handy to have an alias that prints both the command and results to the channel (particularly when you’re running IRSSI on a server). I had previously picked up such an alias from Whales in #rgrd:

/alias do say `$*`; exec -o - $*

(Make sure to save it!)

However, this approach has drawbacks: I convinced Whales to run yes WEED (try it yourself if you don’t know what this does), which got him disconnected for flooding. Since I occasionally do want to run commands that produce a lot of output, I wrote a bash script intended to be executed from IRSSI. Here’s what it does:

/do upload "ls -R ~ | wc -l"

<Eronarn> `upload "ls -R ~ | wc -l"`
<Eronarn> http://eronarn.info/misc/uploads/12/05/19/1337402656.txt

Of course, it’s not really an upload – it’s just piping output into a file on the same server. (Then again, that means it’s that much faster to execute.)

As usual, my code is on Github. However, I’ll leave it here too to pad out my word count:

COMMAND=$1
URL="http://eronarn.info/misc/uploads"
DIR=/srv/http/misc/uploads
M=$(date +%m)
D=$(date +%d)
Y=$(date +%y)
T=$(date +%s)
FILE=$T.txt
OUTPUT="input: $COMMAND
output:
"
cd $DIR
if [ ! -d "$Y" ]; then
 mkdir $Y
fi
cd $Y
if [ ! -d "$M" ]; then
 mkdir $M
fi
cd $M
if [ ! -d "$D" ]; then
 mkdir $D
fi
cd $D
OUTPUT=$OUTPUT$(eval $COMMAND)
echo -e "$OUTPUT" > $FILE
echo $URL/$Y/$M/$D/$FILE

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>