Search Results

Search: Posts Made By: pflynn
Forum: Programming 08-21-2012
1,202
Posted By pflynn
This is definitely the best book on Linux...
This is definitely the best book on Linux programming (on the Linux programming interface, more accurately). But there is an alternative you should try: Advanced Linux Programming, by Mark Mitchell,...
Forum: Programming 04-13-2012
16,756
Posted By pflynn
This is an important difference between the C and...
This is an important difference between the C and the C++ languages. In C++, declaration of function prototypes are mandatory. In C, they are recommended, but not mandatory.
10,682
Posted By pflynn
The original name is obscure, and this is the...
The original name is obscure, and this is the same with many Unix commands. dd(1) is a classical example. What is the meaning of the name dd? And yes, Wikipedia is not accurate. But one cannot just...
10,682
Posted By pflynn
Yes. There are as many interpretations for the...
Yes. There are as many interpretations for the command name as we want. According to Wikipedia:

The su command, also referred to as super user[1] substitute user, spoof user, set user or switch...
Forum: Programming 03-23-2012
1,967
Posted By pflynn
As another suggestion, try the getopt_long(3)...
As another suggestion, try the getopt_long(3) function, if your system supports it. Maybe you could even build your own C++ wrapper to this function.
Forum: Programming 03-23-2012
3,594
Posted By pflynn
I would suggest you prefer strncat to strcat....
I would suggest you prefer strncat to strcat. strncat is the secure sister of strcat:



strncat - C++ Reference (http://www.cplusplus.com/reference/clibrary/cstring/strncat/)

usage of strncat...
12,561
Posted By pflynn
Well, I don't know how you can do this on the IBM...
Well, I don't know how you can do this on the IBM AIX, but since it's a commercial grade Unix system, I'm almost sure there is way you can do this. Unfortunately the solution to this problem is...
12,561
Posted By pflynn
OK. If you want to audit a pre defined set of...
OK. If you want to audit a pre defined set of files, so there is a way you can do this if your system is a Linux system and it has a kernel with the auditing infrastructure enabled ( a kernel built...
12,561
Posted By pflynn
Do you mean the last user who changed some file?...
Do you mean the last user who changed some file? There is no Unix filesystem I'm aware of that stores this sort of meta-information.
Forum: Programming 03-21-2012
2,624
Posted By pflynn
Yes Rink, but be aware that for string...
Yes Rink, but be aware that for string comparisons, strcmp - and its safe version, strncmp - are better suited, since they are specifically designed for working with strings.
Forum: Programming 03-21-2012
2,624
Posted By pflynn
To the program work the way you expect, you need...
To the program work the way you expect, you need to initialize the str and str2 memory areas with the same values (say, with all zeroes, for example):


(...)
char str[20];
char str2[20];
...
Forum: Programming 03-20-2012
8,965
Posted By pflynn
You can visualize what Corona688 said by...
You can visualize what Corona688 said by "forcing" a context switch: if you put the main thread to sleep "for enough time" just after the new thread creation:


int main()
{
pthread_t tid1,...
Forum: Programming 03-17-2012
16,851
Posted By pflynn
For C programs in Unix environments, the regex...
For C programs in Unix environments, the regex and the PCRE (Perl Compatible Regular Expressions) APIs, as suggested, will be the natural solution. The former is a POSIX.1 standard, and the later is...
Forum: Programming 03-04-2012
3,611
Posted By pflynn
Have you ever heard about manual sections? I...
Have you ever heard about manual sections? I suggest you read the man's own man page to check this.
Forum: Programming 02-07-2012
1,727
Posted By pflynn
If you want to see the code with your own eyes,...
If you want to see the code with your own eyes, grab the source code of any implementation of the standard C library, such as the GNU Glibc ( GLIBC, the GNU C Library...
Forum: Programming 01-05-2012
5,311
Posted By pflynn
You have options that range from opening...
You have options that range from opening directories and reading their contents manually ( opendir, readdir), searching for the files (and doing it recursively) to using more specific functions like...
Forum: Programming 12-21-2011
3,072
Posted By pflynn
If using the if bash keyword is not a must, you...
If using the if bash keyword is not a must, you could use the find program to do the job:


find . \( -name "*.dat" -o -name "*.asc" \) -exec rm {} \;


or


find . \( -name "*.dat" -o ...
Forum: Programming 12-18-2011
9,145
Posted By pflynn
I think you had better dynamically allocate the...
I think you had better dynamically allocate the memory to hold the string copy. A fixed length buffer is subject to buffer overflows. strdup(3) would do the work for you. Alternatively, you can use...
Forum: Programming 12-16-2011
72,979
Posted By pflynn
Probably old systems and maybe not so old...
Probably old systems and maybe not so old systems, but with old implementations of the sleep library function. I think we had better do not make any assumptions on whether the sleep function will...
Forum: Programming 12-16-2011
72,979
Posted By pflynn
Looks like you have a typical synchronization...
Looks like you have a typical synchronization problem. One such you would like to use conditional variables to solve. Have a look at pthread_cond_wait, pthread_cond_signal, mutexes and related stuff.
1,156
Posted By pflynn
Yeap...the problem with using single quotes is...
Yeap...the problem with using single quotes is that the shell will not interpolate the variables inside it.
1,156
Posted By pflynn
You should quote the $username variable: ...
You should quote the $username variable:


user_id=`awk -v val="$username" -F: '$1==val{print $3}' /etc/passwd`
Forum: Programming 12-13-2011
2,501
Posted By pflynn
I guess this is because there is a line break in...
I guess this is because there is a line break in the $c variable (or maybe somewhere else). Have you checked it? If you just asign directly the value "Tue Dec" to $c it will work. So probably there...
Forum: Programming 12-13-2011
2,501
Posted By pflynn
Oh, I see. Just remove the backslash before the...
Oh, I see. Just remove the backslash before the $c variable:


$log = ` awk '/$c/' in.txt`;


and it will do the work.
Forum: Programming 12-13-2011
2,501
Posted By pflynn
From where you want to take your contents? From...
From where you want to take your contents? From the shell?


C="Tue Dec"
LOG=`awk '/'"$C"'/' in.txt`
echo $LOG


or from awk itself?
Showing results 1 to 25 of 65

 
All times are GMT -4. The time now is 04:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy