Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, September 20, 2007

rsync

I've just discovered the power of rsync, a Linux utility that allows you to synchronize files on different computers via SSH. This is exactly what I've been looking for because I need a safe and secure yet easily accessible way to store my files for my CPT S 560 class. Here's a quick summary of the command:


To download changes from a remote location -
rsync -ave ssh --delete user@server:folder path

To upload changes to a remote location -
rsync -ave ssh --delete folder user@server:path

The --delete option takes care of files that have been deleted from the source by also deleting them from the destination.

The folder argument specifies the source folder to be transferred. If this argument ends in a trailing slash (/), only the contents of the folder are copied. If there is no trailing slash, the folder is copied along with its contents.

The path argument is the destination to which the files are to be copied.

Tuesday, September 18, 2007

fdisk

I'm writing an fdisk program for my CPT S 560 class right now. An interesting thing I've found is that it only works correctly if I have superuser privileges. At first I thought this was just a mistake in my program, but a non-root shell doesn't even recognize the fdisk command in KDE.

Tuesday, August 7, 2007

getopt Keeps Internal State

Here's the solution to a problem that's been bothering me at work for two days now:

If you want to use getopt more than once within a program, across different inputs, you'll need to reset its internal state counters before each use:

printf("%d %d %d\n",optind,opterr,optopt);
... do getopt stuff ...
printf("%d %d %d\n",optind,opterr,optopt);

This outputs the following:

1 1 63
3 1 63

the '3' in my case is because I only had one option + parameter (+ program name == 3).

So, if you reset optind, opterr and optopt to 1, 1 and 63, before each new use of getopt, you should be fine.

-- Courtesy of DanielLawson and the Waikato Linux Users Group

Wednesday, April 25, 2007

Linutop

This would be a perfect computer for Internet cafes in Third World countries like Rwanda.



Linutop, Plug & Surf