Recent Notes

Displaying keyword search results 1 - 6
Created by magnum on October 22, 2012 19:48:03    Last update: October 22, 2012 19:48:03
execl takes the full path name of the command and variable length of arguments terminated by NULL: execl("/bin/ls", "/bin/ls", "-r", "-t", "-l", NULL... where the second argument is argv[0] , but can be any string! execlp will try to find the command from $PATH , so full path to command is not needed: execl("ls", "ls", "-r", "-t", "-l", NULL); execv is the equivalent of execl , except that the arguments are passed in as a NULL terminated array: char *args[] = {"/bin/ls", "-r", "-t", "-l", NULL ... execvp is the equivalent of execvl , excep that the arguments are passed in as a NULL terminated array: char *args[] = {"ls", "-r", "-t", "-l", NULL }; ...
Created by voodoo on September 17, 2012 15:02:15    Last update: September 17, 2012 15:02:15
Start gdb with the executable and coredump: $ gdb <path to executable> core While in the debugger, use the following commands: (gdb) where ("shows a summary of the stack") ... Example debug session from Debugging Under Unix: gdb Tutorial : Use backtrace (or bt ) to see the callstack: (gdb) backtrace #0 Node<int>::next (this=0x0) ... Inspect the value of item_to_remove at address 0xffbef014 (the value is 1): (gdb) x 0xffbef014 0xffbef014: 0x00000001 (g... Note: The program must be compiled with the debug switch -g in order to see the source code. More resources: Linux software debugging with GDB Debugging with gdb
Created by Dr. Xi on February 07, 2012 15:40:11    Last update: February 07, 2012 15:40:11
An alias defined in .profile does not work when you open a bash window from the desktop. Simply put, alias should be put in .bashrc ; PATH should be put in .profile . These are the facts: .profile is executed by the login shell, i.e., when you login. .bashrc is executed whenever a bash shell is opened - login or non-login. When you open a new bash window from the desktop, a non-login shell is created, it will execute .bashrc , not .profile . When you ssh to a remote system interactively, a login shell is created. When you ssh to a remote system and run a command directly, a non-login shell is created. PATH modifications should be put in .profile since it is usually...
Created by woolf on September 08, 2011 11:19:52    Last update: September 08, 2011 11:19:52
To check a command exists on PATH: Use the return code of which : which some_command &>/dev/null [ $? -eq 0 ] || ... For bash, use type -P : type -P some_command &>/dev/null && echo "ome_comm... or check_path() { if ! type -P $1 &> /dev/...
Created by Dr. Xi on February 17, 2011 14:06:22    Last update: February 17, 2011 14:06:22
This is the crontab to run a cron job every 15 minutes: */15 * * * * /path/to/executable >/redirect/output... or, 0,15,30,45 * * * * /path/to/executable >/redirect/... In general, the format is: minute hour day_of_month month day_of_week command Valid values are: Field Value minute 0-59 hour 0-23 day of month 1-31 month 1-12 day of week 0-6 (Sunday = 0) Reference: crontab(5) - Linux man page
Created by Dr. Xi on June 02, 2007 02:11:54    Last update: August 20, 2007 03:26:54
Use the ldd command to display shared library (dynamic) dependencies of an executable or shared library object. This is a typical output: [patrick@dellpc ~]$ ldd /bin/ls linux-g... If ldd complains that some library can't be found, you can set the environment variable LD_LIBRARY_PATH to alter the search path for shared libraries.