I found quotes are little bit tricky and confusing in Shell Script. Below is about them got from freeos.com
"Double Quotes" - Anything enclose in double quotes removed meaning of that characters (except \ and $).
'Single quotes' - Enclosed in single quotes remains unchanged.
`Back quote` - To execute command.
Also, it looks like interpreter converts all the "Double Quotes" into 'single quotes' and again executes this resulted one with single quotes. You can get this from the output if you have "#!/bin/sh -vx" as first line in your script.
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Thursday, 13 December 2007
Tuesday, 23 October 2007
Found some interesting link - Binary Patching
For Binary patching, here is the link. Nice idea where you modify the binary files contents. Ofcourse, its not new completely, as already there are ways injecting data into images (I guess this is termed as Watermarking), but, this is useful one.
Friday, 7 September 2007
Changing the format of the coredump file name
When any program crashes, it dumps core. File name format of the core that gets created can be controlled using sysctl.
One way is: sysctl -w "kernel.core_name_format=/coredumps/%H-%N-%P.core"
%P The Process ID (current->pid)
%U The UID of the process (current->uid)
%N The command name of the process (current->comm)
%H The nodename of the system (system_utsname.nodename)
%% A "%"
Got this from the link.
One way is: sysctl -w "kernel.core_name_format=/coredumps/%H-%N-%P.core"
%P The Process ID (current->pid)
%U The UID of the process (current->uid)
%N The command name of the process (current->comm)
%H The nodename of the system (system_utsname.nodename)
%% A "%"
Got this from the link.
Thursday, 7 June 2007
Memory Related issues detection tool
Since last 3 to 4 days, I hadn't done even a single defect fix. Time was getting consumed in reviews, meetings and investigations. In the last 3 days, I was getting tired too much. Finally, found the reason for that - I was not hearing to Music last 3 days. Ok, this blog is to explain some tool that I learnt today in detecting memory issues like leaks, corruptions, heap usage etc....
It is MemoryScape. Its a good tool. This can be attached to the running process, or the core that got generated or the new program that to be started.
First, faced problems in attaching this to my binary file - as my binary file not generated using the libraries provided by this tool. Finally was able to do by using LD_PRELOAD environment variable.
But, leaks reporting is not happening. That tool provides some so's. At the time of linking, it makes any fork or malloc or free calls to its functions and then it tracks them. And, then, internally, they call the original functions.
Attached para is copied from its document:
Behind the Scenes
MemoryScape intercepts calls made by your program to heap library functions that allocate and deallocate memory by using the malloc() and free() functions and related functions such as calloc() and realloc(). The technique it uses is called interposition. Our interposition technology uses an agent routine to intercept calls to functions in this library.
Courtesy: www.totalviewtech.com
In the similar way, fork also gets intercepted. Just compiled my code with them and yet to test them. In the mean while compilation is going, thought of putting this here....
It is MemoryScape. Its a good tool. This can be attached to the running process, or the core that got generated or the new program that to be started.
First, faced problems in attaching this to my binary file - as my binary file not generated using the libraries provided by this tool. Finally was able to do by using LD_PRELOAD environment variable.
But, leaks reporting is not happening. That tool provides some so's. At the time of linking, it makes any fork or malloc or free calls to its functions and then it tracks them. And, then, internally, they call the original functions.
Attached para is copied from its document:
Behind the Scenes
MemoryScape intercepts calls made by your program to heap library functions that allocate and deallocate memory by using the malloc() and free() functions and related functions such as calloc() and realloc(). The technique it uses is called interposition. Our interposition technology uses an agent routine to intercept calls to functions in this library.
Courtesy: www.totalviewtech.com
In the similar way, fork also gets intercepted. Just compiled my code with them and yet to test them. In the mean while compilation is going, thought of putting this here....
Wednesday, 6 June 2007
Finding large files in your linux box
My HD was reaching 100% usage now and then. So, I want to find large files in my box and delete them. I don't know scripting. Google made me to reach here.
find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
In some linux boxes, we may need to change the parameter $9 for print as $8 or something else
Got the above one from this place
Just thought of putting it here
find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
In some linux boxes, we may need to change the parameter $9 for print as $8 or something else
Got the above one from this place
Just thought of putting it here
Subscribe to:
Posts (Atom)