Register
It is currently Mon Dec 22, 2014 2:53 pm

Strip extra stuff from mirc/ cut-n-paste


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Fri Mar 25, 2011 10:24 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
At work, we use windows (yuck), and our irc client is mirc.
When pasting code back and forth via mirc's chat window, sometimes we want to quickly
strip out the extra stuff mirc puts in.... this does the trick pretty quickly.

Code:
#!/usr/bin/bash
# stripmirc - strips fields from mirc copy/paste
# crouse
export TERM=xtermc
timestamp=`date +%T`
tempfile="/tmp/mirc.$timestamp.tempfile"
touch ${tempfile}
# TRAP  for the cleanup routine in case bad stuff happens.
trap cleanup 1 2 3 6
# Function for deleting files not needed.
cleanup ()
{
  rm ${tempfile}
}
echo "Type CTRL D to end"
cat > ${tempfile}
echo "";echo "";echo "";
cat ${tempfile} | cut -d" " -f 3-
rm ${tempfile}
exit 0


Top
 Profile WWW  
 PostPosted: Mon Mar 28, 2011 7:26 am   

Joined: Mon Mar 28, 2011 7:22 am
Posts: 5
Gday,


Not 110% sure what mIRC has got to do with it, but my 2 cents say control+shift & highlight will capture all color/colour ascii-codes for you to paste elsewhere.

cheers.


Top
 Profile  
 PostPosted: Wed Jun 01, 2011 9:47 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
ok.......

it takes something that looks like this in my mirc irc window:
Code:
[10:45] <davec> #!/opt/csw/bin/bash
[10:45] <davec> # This is bash 4.0
[10:45] <davec> # This file is under revision control. Edit with RCSedit.
[10:45] <davec> # Date: 03-18-2010
[10:45] <davec> # Created by Crouse
[10:45] <davec> # Filename: tweet
[10:45] <davec> # Usage: tweet
[10:45] <davec> # Notes:  Crouse's bash tweeter for twitter.
[10:45] <davec> #         Asks for the tweet you want posted.
[10:45] <davec> #         Must be less than 140 chars.
[10:45] <davec> read -p "Enter Your Tweet: " TWEET
[10:45] <davec> countme()
[10:45] <davec> {
[10:45] <davec>     count=`echo "$TWEET" | wc -m`;
[10:45] <davec>     [[ $count -gt 140 ]] && echo "Tweet is $count characters (Maximum 140 characters!) TWEET was NOT sent!" && exit
[10:45] <davec> }
[10:45] <davec> countme
[10:45] <davec> echo "SENDING ...."
[10:45] <davec> curl -u bashscripts:XXXXXXXXXX -d status="$TWEET" http://twitter.com/statuses/update.xml -o /dev/null
[10:45] <davec> echo "SUCCESS ! Your tweet was tweeted."
[10:45] <davec> exit 0


and makes it look like this

Code:
#!/opt/csw/bin/bash
# This is bash 4.0
# This file is under revision control. Edit with RCSedit.
# Date: 03-18-2010
# Created by Crouse
# Filename: tweet
# Usage: tweet
# Notes:  Crouse's bash tweeter for twitter.
#         Asks for the tweet you want posted.
#         Must be less than 140 chars.
read -p "Enter Your Tweet: " TWEET
countme()
{
    count=`echo "$TWEET" | wc -m`;
    [[ $count -gt 140 ]] && echo "Tweet is $count characters (Maximum 140 characters!) TWEET was NOT sent!" && exit
}
countme
echo "SENDING ...."
curl -u bashscripts:XXXXXXXXXX -d status="$TWEET" http://twitter.com/statuses/update.xml -o /dev/null
echo "SUCCESS ! Your tweet was tweeted."
exit 0


Does that explain what it does better ?


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP