Blog Posts
Moving quickly from anywhere with $CDPATH
Tips Shell
September 27, 2006 | COMMENTS

Do you know the environment variable $CDPATH? This variable let you define some path where to look for a directories when moving with the command CD. You can define multiple path in this variable. This can be usefull if you have some directories that you access more frequently than the others. As this variable define the order how you move from a directory to another, I suggest you to keep the "." directory in first position of your variable declaration. Of course, you can set this variable in your .bashrc

nicolas@grimm:~$ export CDPATH=.:/:~/  
nicolas@grimm:~$ cd usr<br />
/usr<br />
nicolas@grimm:/usr$ cd Desktop<br />
/home/nicolas/Desktop
1
2
3
4
5
How will be interpreted a command
Tips Shell
September 27, 2006 | COMMENTS

You probably have set some personnal alias or function on your box. Most common is probably dir, ls, ll... If you forgot how you define your alias or function, the easiest way for get back the definition isn't to read your numerous .bashrc but using some bash built-in command : type or command.

type: usage: type [-afptP] name [name ...]
command: usage: command [-pVv] command [arg ...]
1
2

Command is generally used for running command with arguments ignoring any shell function named command. Instead of Type that describe a command, for each name, indicate how it would be interpreted if used as a command name. But both can be used, here is some examples :

[root@host ~]# alias -p
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
[root@host ~]# command -v rm
alias rm='rm -i'
[root@host ~]# command -V rm
rm is aliased to `rm -i'
[root@host ~]# type rm
rm is aliased to `rm -i'
1
2
3
4
5
6
7
8
9
10
Deactivate windows firewall on startup
Tips Shell
September 27, 2006 | COMMENTS

On some computer that I have to manage remotly I can have some windows upgrade done. But in some case (new software install, or windows update to SP2) the windows firewall is automatically started and you can lost some software access (example : VNC). In my case, the firewalling is managed by another computer (A linux one) on the network and we need for some of our software to have full access to the network without the risk of a windows alert popup. So, I put a small batch file in the Start-up directory with the following line :

NETSH FIREWALL SET OPMODE DISABLE

Now, I’m sure that the firewall will never restart at the boot of the computer. Of course, this configuration require a firewall somewhere on your network between your computer and the internet, don’t forget this or you probably regret it one day.

Delete old files by the last access date
Case Study Shell
September 27, 2006 | COMMENTS

In my professionnal experience I have to manage many PC running with Windows XP. Those box are used for broadcasting some video flow and download lot of media files which aren’t managed by our software. Naturally, I had to find a solution for dynamically purge the lot of useless media files daily generated. As everyone working in system administration (I suppose...), I didn’t have lot of time for doing this job and our software developper couldn’t add the possibility to destroy old files (still due to lot of projects and short timeline...), so I decide to use the Windows schedule (AT) and doing a batch file.

As we had different software version - and for a maximum flexibility in case of any "kidding" evolution of this software - I take care to use arguments to my script. Here by I’ll describe all the process of this script that can be resume in five parts :

  1. Get and check our arguments
  2. Checking some dates (OS date format, maximum vailidity date)
  3. Parsing the directory to purge and get last access date of files
  4. Testing date and delete useless files
  5. Scheduling the batch file
Continue Reading
  • ...