Everybody knows the classic command to make a tar file:
tar -cvf file.tar directory_to_tar
and if you use gnu tar you can improve it with the compress in that step:
tar -zxvf file.tar directory_to_tar
or
tar -jxvf file.tar directory_to_tar
for gzip and bzip respectively...
but did you know:
tar zcvf - /directory_to_tar | ssh hostname "cat > file.tgz"
so you can tar gzip on one end and write the file on the other end of an ssh session?
Huh? Did you?
Yes I know I still owe an automounter deal... I promise it is on the way.
Too busy gardening the Silicon Rust...
Showing posts with label shell scripting. Show all posts
Showing posts with label shell scripting. Show all posts
Friday, August 25, 2006
Tuesday, June 27, 2006
getting rid of standard error
scp foo server: 2>/dev/null
the descriptor 2 is for standard error.
Redirecting 2 to /dev/null makes the standard error go away.
the descriptor 2 is for standard error.
Redirecting 2 to /dev/null makes the standard error go away.
Monday, May 08, 2006
mount loop: cd or dvd iso
if you need to use a dvd or cd iso on your linux box just mount it loop. You can even export or serve out (via http) the mount.
mount -o loop /home/fedora/FC3-i386-DVD.iso /home/fedora/pub/mirrors
and that makes gardening a little easier...
mount -o loop /home/fedora/FC3-i386-DVD.iso /home/fedora/pub/mirrors
and that makes gardening a little easier...
Sunday, April 23, 2006
What do you do to emulate a server?
So I get one of those typical gardening compalints, "I can't communicate to my server that is running on port 3000...what is wrong?"
Well, first I "netstat -an | grep 3000", looking for a deamon listening on 3000. Nothing. No server, no communication. But I don't know the server software well enough to start it up (custom, not init.d script). So I whip out netcat (could be nc on some platforms) and start it listening as a deamon:
netcat -l -p 3000
netcat listen on port 3000. Any thing netcat recieves will be output to std out. So now from a host that should be able to connect to the server on 3000, "telnet servername 3000". Connected and things type appear on the terminal. Looks good.
Looks the the problem is the server software. Back to your application, developer.
Well, first I "netstat -an | grep 3000", looking for a deamon listening on 3000. Nothing. No server, no communication. But I don't know the server software well enough to start it up (custom, not init.d script). So I whip out netcat (could be nc on some platforms) and start it listening as a deamon:
netcat -l -p 3000
netcat listen on port 3000. Any thing netcat recieves will be output to std out. So now from a host that should be able to connect to the server on 3000, "telnet servername 3000". Connected and things type appear on the terminal. Looks good.
Looks the the problem is the server software. Back to your application, developer.
Tuesday, April 11, 2006
Two ways to sync files on servers.
Two ways to synchronize files:
rsync over ssh (superhandy with keys and a key agent):
rsync -av source destination
Where source and destination are ssh style: username@host:/path/to/
Another nice way to sync files is rdist.
rdist allows you to sync files to many nodes from a master (it is easy to set up and configure).
It is very handy. It is probably included with your distribution, it is definately used by several webservice providers and the homepage is here: http://www.magnicomp.com/rdist/
rsync over ssh (superhandy with keys and a key agent):
rsync -av source destination
Where source and destination are ssh style: username@host:/path/to/
Another nice way to sync files is rdist.
rdist allows you to sync files to many nodes from a master (it is easy to set up and configure).
It is very handy. It is probably included with your distribution, it is definately used by several webservice providers and the homepage is here: http://www.magnicomp.com/rdist/
Saturday, April 01, 2006
Sending attachments from a script or Linux CLI
mutt -s SUBJECT -a ATTACHMENT user@domain.com
is a nice way. I like mutt as a mail user agent. It can do pgp and stuff too if you need to.
mailx is another way. I prefer mutt, but now you have at least two ways to send attachments from a linux script or command line.
UPDATE:
A third way posted by anonymous in the comments:
uuencode local_file.name remote_file.name | mail -s "file attachment" user@example.com
if you have uuencode installed and mail, it works very well. Thanks anonymous!
is a nice way. I like mutt as a mail user agent. It can do pgp and stuff too if you need to.
mailx is another way. I prefer mutt, but now you have at least two ways to send attachments from a linux script or command line.
UPDATE:
A third way posted by anonymous in the comments:
uuencode local_file.name remote_file.name | mail -s "file attachment" user@example.com
if you have uuencode installed and mail, it works very well. Thanks anonymous!
Subscribe to:
Posts (Atom)