Tuesday, December 30, 2008

mutt forward mail with attachments

1) 'b' bounces the message completely unmodified to a new address

2) 'Esc E' uses a current message as a template for a new message,
can modify attachments and text

*) Esc F to clear the "From" address (Esc F) from the send men

*) S to change subject


Thursday, December 18, 2008

xargs with complicated command line

xargs will pipe to a command. what if it has complex structure?
ls $1 | xargs -I {} -t mv $1/{} $2/{}

here the I command says use {} to replace the piped output

thus we use

find . -iname '*nons*' -print0 |xargs --null -I {} cp {} ../nonstandard-analysis/{}

to deal with
1) spaces in output file names from find we use -print0 and
correspondingly to match we use xargs --null

2) to deal with the xargs applied command which has multiple arguments we use the -I {}
to fill in for the xargs output

cool!

Sunday, December 14, 2008

Problem with refiltering a Mail directory

I decided to split my perldl messages from incoming directory
however when I foolishly decided to run

http://markmail.org/message/tz6isa4n4ubyssuc#query:rerun procmail on a maildir+page:1+mid:tukr7f524zmykz7n+state:results



#/usr/bin/sh
cd Mail/inbox/cur
for file in *; do
procmail < $file
done

this gave me multiple copies of the original mails
then if I ran this multiple times I had a mess with 30,000 mails in my inbox
instead of 4301
so I had to run this
script-dealwithdups.pl
#!/usr/bin/perl -w
use strict;
use File::Find::Duplicates;
my $in=shift;

my @dupes = find_duplicate_files("$in");
my $length;
foreach my $dupeset (@dupes) {
my $length= scalar @{$dupeset->files} ;
if ($length >= 1) {

for (my $i=0; $i<$length -1 ;$i++) {
#print $ { $dupeset->files} [$i]; print "\n";
unlink $ { $dupeset->files} [$i];
}
}
where I got File::Find::Duplicates from CPAN

Tuesday, December 9, 2008

disable ssh timeout how to

Disable SSH timeout

http://www.techrecipes.net/linux/disable-ssh-timeout.html

By default, most SSH servers are configured to forcibly disconnect inactive or idle clients, or actually those with no network activity. This is not good for some people especially if one is setting up a (reverse) tunnel to the server where the tunnel should remain established whenever they need it.

There are 2 methods to overcome this problem,
1) not to stay idle or by keeping the network activity busy, and
2) if you have root access to the server, change the SSHd configuration at the server.

How can the network be kept busy while you are not attending the session? The trick is to run any program that keep updating the screen, such as mtr or top. The program should generate some network activity, and keep the session active and connected. Use the program screen to create virtual terminals where one terminal is dedicated to the program mtr or top.

If you have root access to the server, you might want to just change the SSHd configuration file. To do this, edit the file /etc/ssh/sshd_config and change the following options as in the example below;

TCPKeepAlive yes ClientAliveInterval 30 ClientAliveCountMax 99999

Don’t forget to restart the SSH server afterwards with the following command;

# /etc/init.d/sshd restart