Archive for the 'Software' Category

Mounting drives in Linux

Tuesday, August 9th, 2011

Sometimes you have a drive that your want to mount under Linux. The mount command can make the drive available to you. But you need to also create a directory to hold the mount point.

mkdir /mnt/drivepoint

Then you can mount the drive to that mount point by using the mount command and giving the device identifier, in this case it is /dev/sda1, and the mount point which we created as /mnt/drivepoint. One thing to note, is that the mount will use whatever directory you specify, so if there are files located in the directory you use as a mount point, they will no longer be visible.

mount /dev/sda1 /mnt/drivepoint

This must be run as root or with the sudo command.

Tags: , ,

Using tar over ssh

Thursday, July 21st, 2011

Every once in awhile, I need to backup a large directory from another computer. This can be done by creating a zip or tar of the files you are looking to save and then copying those zips to the other computer. But what it you have a very large directory and not enough room to store the extra file. Here is a way to use tar over ssh:

ssh tar zcvf – /wwwdata | ssh root@backupserver.mydomain.com “cat > /backup/wwwdata.tar.gz”

Setting timestamp with Touch

Wednesday, July 20th, 2011

Did you know? You can Set file timestamp using touch command. One way to do this is:
touch -c -t YYMMDDhhmm filename.txt

Utility: Find files files older than a certain amount of days

Monday, June 13th, 2011

I had to write a backup script the other day and used the find command to find the files that were older than a given amount of days.

DAYS_TO_KEEP=7
find /path/to/files* -type f -name *.bak -mtime $DAYS_TO_KEEP -exec rm {} ;

The -name argument uses the escaped asterisk so command completion does not replace it with all the file names.

The -mtime argument takes a number that is the number of days to look at.

The -exec argument takes a command and the {} is replaced with the current file name and the ; is the end of the command.

This is a small part of the power of the find command.

Windows: Grep for windows

Monday, May 2nd, 2011

If you don’t have access to a Unix environment on your windows box, you can still search files with findstr. The findstr command will allow you to search files close to the same way as grep.

findstr /S "search string"

will recursively find your string in the current directory and subdirectories.

There are more options that you can find if you run the following command:

findstr /?

will show you the help message.

Tags: ,

Linux: watch command

Monday, March 14th, 2011

So every once in a while I want to see the progress of an upload or backup. So I turn to the watch command in Linux. The watch command gives the user the ability to re-run a command and see the updated output.

The syntax is ‘watch -n -d .

So for watching a file downloads progress you could run the following:

watch -n 30 ls -l filedownloading

This would show the ls output and you could watch the size of the file grow as it is dowload progress.

Ant unable to find tools.jar

Saturday, January 29th, 2011

When attempting to run ant I get the following message: “Unable to locate tools.jar. Expected to find it in C:Program Files (x86)Javajre6libtools.jar”

This had to do with my JAVA_HOME not pointing to a Java JDK.

So if you download a JDK and update your JAVA_HOME environment variable to point to that directory, ant should run happily.

In BASH:
export JAVA_HOME=/path/to/jdk

IN DOS:
set JAVA_HOME=c:PATHtojdk

Tags: ,

Sample Ant file

Friday, January 28th, 2011

Every once in awhile I go back and try to figure out how to create a basic ant build.xml file. So I am just placing a sample build.xml here.

The directory structure should be something like
./build.xml
./src/HelloWorld.java

The targets will create the build directory and compile the source and run a test execution of the class.

<project name="HelloWorld" basedir="." default="main">
<target name="clean">
<delete dir="build"/>
</target>

<target name="compile">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"/>
</target>

<target name="jar" depends="compile">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/HelloWorld.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="HelloWorld"/>
</manifest>
</jar>
</target>

<target name="run" depends="jar">
<java jar="build/jar/HelloWorld.jar" fork="true" />
</target>

<target name="main" depends="clean,run"/>

</project>

Tags:

Toggle wrap in VI

Sunday, October 31st, 2010

This turns off word wrap in the vi window

:set nowrap

to enable it again:

:set wrap

Tags: ,

Apple iTunes doesn’t allow purchased apps to go back to device

Wednesday, August 4th, 2010

I have been frustrated by the crappy Authorization scheme on the iTunes store for quite some time. Purchased apps tell me that I am not authorized to use them and will not restore any apps to my device.

I already had to restore from a backup because the phone froze in a screen backlight issue and now cannot get back many of my apps to the device.

This is making me want to get rid of my iPhone and go to a device that is not so locked down. I should be able to put apps that I got legitimately back to my own device.