2011年12月14日 星期三

How to change a file association with command line in Windows system (XP, Vista, 7)?

To change a file association with command line in Windows system (XP, Vista, 7)

Two commands are involved, assoc & ftype.

Example No1: 

We want to use Notepade++ to open text file instead of Notepad.

C:\assoc .txt

.txt=txtfile

C:\ftype txtfile

txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1

ftype txtfile="C:\Program Files\Notepad++\notepad++.exe" "%1"

 

Example No2:

We have a customized application, ezPGPClient, which can encrypt and decrypt files with PGP standard.

It's located in C:\pnab\program\ezpgp\ezPGPClient.exe

The file extensions will be associated are .gpg and .pgp and there is no other program had been set up to association with them.

C:\assoc .gpg=pgpfile

# This command assign .gpg to be pgpfile

 

C:\assoc .pgp=pgpfile

# This command assign .pgp to be pgpfile

 

C:\ftype pgpfile=C:\pnab\program\ezpgp\ezPGPClient.exe %1

# This command assign pgpfile to be opened by the given program with absolute path.

2011年12月9日 星期五

Linux cron job

To add a cron job,

crontab -e

=============================================

0 0 * * * /opt/ezpgp/cmds/ezDailySync.sh >/tmp/dailysync.txt 2>&1

=============================================

The example above, will execute ezDailySync.sh at 0:0 every day.

分 時 日 月 週 |<==============指令串========================>|

To list the current cron job,

crontab -l

find how many keys are in key server

To find how many keys are in key server, please run this command in each server.

ldapsearch -H ldap://127.0.0.1 -x -b "ou=PGP Keys,dc=tsmc,dc=com" "(pgpUserID=*)" pgpKeyID -LLL | grep pgpKeyID |wc -l

 

If you want to compare the result on both server, please run this command in each server and redirect the output to a text file.

ldapsearch -H ldap://127.0.0.1 -x -b "ou=PGP Keys,dc=tsmc,dc=com" "(pgpUserID=*)" pgpKeyID -LLL | grep pgpKeyID | sort

2011年12月5日 星期一

How to check if my text or script does have “carrage return” CR in Linux

For example, I have a script called myscript.sh

Command:

$ cat –v myscript.sh

If I forgot to convert it into Unix format, I would have a output like this:

#! /bin/bash^M
^M
echo "Steve"^M
echo "Test"