LAMP On Focus

Icon

PHP, MySQL, Linux practical usage.

Subverion : Check out files affected during a specific commit revision

I am using SVN for my code management, and recently I needed to get only the files that where commited on a particular version. Looking around there was no straight way of doing this. But, this can be achived by the following steps.,
Get the list of files commited on a particular revision number.
svn log </local/svn/checkout/path/> -qv -r<revision_number> | awk '/\//{print $2}'

 svn log /home/raja/coderepo/ -qv -r12423 | awk '/\//{print $2}' 

Export the files one by one by specifying the filename & revision number explicitly.
svn export -r<revision_number> <repository_url> <target_directory>/<file_name>

 svn export -r12423 http://svn.rajavarma.com/trunk/ /home/raja/svndump/r12423/myfile.php 

Have wrapped the process in a simple PHP script which you can download svn.export.revision.files.php here.

Run ifconfig as a non-root user

Recently I needed to extract the ip number of the box on which my script was running, and had to decide the behaviour of tool.
Upon digging around, worked out a command snippet that worked, as given below.

ifconfig eth0|sed -n "/inet addr:.*/{s/.*inet addr://; s/ .*//; p}"

But the problem was ifconfig only works as a `root` user if you try it as a normal user you would get a command not found.

$ ifconfig
-bash: ifconfig: command not found

The problem is the `sbin` folder under which the `ifconfig` command resides is not added to the`PATH` environment variable by default.

all you have to do is the following.

$ export PATH=$PATH:/sbin
$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/raja/bin:/sbin

Now as we have added the `sbin` folder to the `PATH` variable, try the command again it will work.

You don’t want to set the path each time you login. You can add it to your `.bashrc` file in your home folder to update the path
automatically each time you login.

Here is how you do it.,

$ vi ~/.bashrc

add the following line at the end of the file.

export PATH=$PATH:/sbin

Save and close the file. From the next time you log-in the `sbin` folder will be available to your `PATH` variable.

In case you need to reload the .bashrc file immediately issue the following command

$ source ~/.bashrc

NOTE : It works only on a readonly mode. Trying to set the interface parameters as a non root user will generate error.

$  ifconfig eth0 192.168.0.1
SIOCSIFADDR: Permission denied
SIOCSIFFLAGS: Permission denied

Calendar

March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031  

Bookmarks

  • No bookmarks avaliable.

Friend Connect