Posted by: Gangadhar on: August 20, 2009
Have you even wondered how many physical/virtual processors your machine is having? Well, you psrinfo is the command which can display that information.
psrinfo – displays information about processors.
prtconf - print system configuration.
dmesg - collect system diagnostic messages to form error log.
Ex:
(My machine is having 4 physical processors which are divided into 8 Virtual processors)
$> psrinfo -p
4
$> psrinfo -pv
The UltraSPARC-IV physical processor has 2 virtual processors (0, 16)
The UltraSPARC-IV physical processor has 2 virtual processors (1, 17)
The UltraSPARC-IV physical processor has 2 virtual processors (2, 18)
The UltraSPARC-IV physical processor has 2 virtual processors (3, 19)
Refer the man pages for more information on the above commands.
Posted by: Gangadhar on: June 17, 2009
One must be wondering how come the executable permission of a shell script file got changed after check-in. Well, at least I did when I need to re-release the patch just because of these Permissions.
Usually, when we make some script file to Clearcase elements, its permission will still be maintained. But when we check-in the same file, it’ll be having Read-Only permissions.
So, how to retain the permissions of a file after check in also? Use ‘protect’ option.
ct protect -r -chmod 555 <directory-or-file-name>
Note: ‘-r’ option is valid only for Directories.
Posted by: Gangadhar on: March 26, 2009
Have you ever wondered why there is no toUpper() kind of function in shell script? Well, i think the reason is typeset command.
What does it do exactly? A lot:
* Set a parameter as an integer by using -i option so as to fasten the arithmetic operations on that variable.
* Convert to lower case using -l
* Mark a variable as Read-only using -r
etc…
Converting into upper case? Yes, you guessed it right, use -u option.
How to use it? You can use it before assignment or after assignment, does not make much difference.
Whats more? You can even give more that one variable to this typeset command.
For more information on typeset, use man typeset.
Posted by: Gangadhar on: March 12, 2009
How do one can rename a Clearcase View on Unix/Linux/Solaris? Very simple, use rename command. :-p
Just kiddin, never mind.
Well, renaming a Clearcase View requires the renaming of both the storage and the tag. Here are the basic steps for the same but you are recomended to refer the Product Documentation if it doesn’t work:
1. Stop the view
PROMPT> cleartool endview <view-tag>
2. Remove the view tag to untag the view
PROMPT> cleartool rmtag -view <view-tag>
3. Remove the Clearcase registry entry to unregister the view object
PROMPT> cleartool unregister -view <vie-storage-path-name>.vps
4. Rename the view storage directory
PROMPT> mv <old-view-storage>.vps <new-view-storage>.vps
5. Register the new name fo the view storage
PROMPT> cleartool register -view <new-view-storage-path-name>.vps
6. Create a new tag for the view
PROMPT> cleartool mktag -view -tag <new-view-tag> <new-view-storage-path-name>.vps
As it is on Solaris machine, no need to start the view explicitly. You can directly start working by setting the new view.
Note: These steps are just for rename operation. If you wish to move, not rename, the snapshot view directory which contains special files, you need to take some additional steps.
Posted by: Gangadhar on: March 9, 2009
You can install any package using ppm command on windows.
Ex: From command prompt, execute ppm:
C:\perl> ppm
Then the prompt changes and you can install the DBI using the following command:
Install DBI
In the same way, you can install other packages also.
Posted by: Gangadhar on: February 20, 2009
I think most of us know the DOS command “time/T” which displays current system time without prompting for new time.
But If one needs more granular output, say in HH:MM:SS format, here is a way out, use “echo %TIME%” which expands to current time using same format as TIME command.
There are so many other things which can be echoed. For example, try any of the following variables:
%CD% – expands to the current directory string.
%DATE% – expands to current date using same format as DATE command.
%RANDOM% – expands to a random decimal number between 0 and 32767.
%ERRORLEVEL% – expands to the current ERRORLEVEL value
%CMDEXTVERSION% – expands to the current Command Processor Extensions version number.
%CMDCMDLINE% – expands to the original command line that invoked the Command Processor.
%PATH% – expands the current PATH variable.
etc….
Posted by: Gangadhar on: December 17, 2008
We can use expect to automate the interactive scripts which may expect some inputs from the user. Search in the net for more info.
Following code snippet can give you can idea how an expect script may look like. The “cmdFile” may contain some commands to achieve some functionality like changing the current directory and putting some files in it.
#!/usr/local/bin/expect
spawn sftp -b cmdFile ganga_k@172.16.2.21
expect “password:”
send “password\n”;
interact
Posted by: Gangadhar on: December 17, 2008
To run a shell script in DEBUG mode, put “-x” option at the end of the interpreter in the first line.
#!/usr/local/bin/sh –x
This is going to print the steps the compiler goes through.
Posted by: Gangadhar on: December 17, 2008
The “default” case in a switch case need not be perfect by its spelling. If none of the cases satisfy the condition, the compiler will search for “default” case. If its there, it’ll execute that block. In case you have miss spelled it [may be in hurry!
], the compiler won’t give any error, but it won’t go for that block as it is not “default” block.
So be careful while using switch statement.
Posted by: Gangadhar on: December 17, 2008
“stdout” flushes the data to be printed to standard output device only after getting an new line character. If it wont get a new line character, it waits until the program ends, then it flushes the data.
Ex:
Code:
#include<stdio.h>
int main()
{
fprintf(stdout,”hello-out1 \n”);
fprintf(stdout,”hello-out2 “);
fprintf(stderr,”hello-err “);
return 0;
}
Output:
hello-out1
hello-err hello-out2