Skip to main content

Posts

Showing posts with the label Linux

Resuming scp

I was transferring a file from one system to another at work with scp when the connection dropped. It was a substantially sized file and I didn't want to start the transfer over again, but unfortunately scp doesn't support resume. That's when I remembered rsync. With rsync I was able to continue the transfer where it left off, and afterward I had the idea to set the following alias in my .bashrc file. alias scp='rsync -vPe ssh' Now when I transfer files with scp, I'm really using rsync and I don't have to worry about flaky network drops.

Creating a CentOS-Based LAMP Virtual Image

In doing some preliminary research and planning for a client's new project, I determined his current in-house deployment platform would not be sufficient given his requirements. Specifically, the project calls for a moderate amount of URL re-writing and the ability to programmatically FTP files to a remote host. The client is running IIS on Windows Server 2008; I’m not too keen on ISAPI rewrite and IIS Rewrite seems to have fallen off the face of the Internet, and the ftp_ssl_connect() function is only available in PHP if both the ftp module and OpenSSL support are statically built-in so we would have to maintain a build environment for him, too. A LAMP-stack makes more sense. Apache can rewrite URLs with mod_rewrite and compiling PHP is a more supported practice on Linux than it is on Windows. I discussed the obstacles and some possible solutions with the client and he's okay with LAMP. Instead of bringing in more hardware, though, I suggested taking advantage of virtualizat...

Seamless Error Highlighting

A lot of output can be generated when you compiling large projects. When it breaks, it can be difficult to identify the particular spot in the build-process where things when wrong. Highlighting the error messages can help them stand out from the rest of the output. ANSI escape sequences can be used to modify how your terminal window displays its text. For example, outputting the sequence \033[41;37mHello World\033[0m would result in "Hello World" displayed in white text against a red background. Escape sequences begin with an escape character (ASCII 27, octal 033) and bracket. The control values are then given (multiple values are semicolon-separated) and the entire sequence closes with m . You can highlight certain messages by routing the STDOUT and STDERR streams to sed and performing a replacement. s,(.*error.*|.*fail.*|.*undef.*),\033[41;37m\1\033[0m,gi The values you match are of course entirely up to your discretion. The tricky part is quoting and escaping the ...