Often when adding a method to a shared library, the method can't be found when accessed from another program. You start to wonder whether you made a mistake and whether the new method was indeed added. A simple way to check is to use the "nm" command e.g.
nm libraryname.sl
This lists all the symbols so best to do something like:
nm libraryname.sl | grep nameofmethod
Enjoy!
Ideas and thoughts about Microsoft Identity, C# development, cabbages and kings and random flotsam on the incoming tide
Monday, July 03, 2006
Unix : Sorting directory by date (ls -ltr)
Almost everyone knows the
ls -l
command to display information about the contents of a directory. Sometimes you need to display it in date order so
ls -lt
To display in ascending date order (i.e. most recent last)
ls -ltr
Enjoy!
ls -l
command to display information about the contents of a directory. Sometimes you need to display it in date order so
ls -lt
To display in ascending date order (i.e. most recent last)
ls -ltr
Enjoy!
Monday, May 29, 2006
C - Premature end-of-file (EOF)
So there I was writing a C program on Windows to change some fields in a binary file and copy the rest over as is. The problem was that the output file was always smaller than the input file? A little research showed that the problem was a 0x1A in the file. This is interpreted as an EOF.
Aside: This dates from MS-DOS days. The ASCII character 0x1A or 26 decimal (the "SUB") character was used as the end of file marker for text files. This mode also translates "\r\n" to "\n" for reading and translates "\n" to "\r\n" for writing.
The solution is to read and write the file as binary i.e.
fopen ("File", "rb") or fopen ("File", "wb") where the "b" indicates binary.
Enjoy!
Aside: This dates from MS-DOS days. The ASCII character 0x1A or 26 decimal (the "SUB") character was used as the end of file marker for text files. This mode also translates "\r\n" to "\n" for reading and translates "\n" to "\r\n" for writing.
The solution is to read and write the file as binary i.e.
fopen ("File", "rb") or fopen ("File", "wb") where the "b" indicates binary.
Enjoy!
Thursday, May 25, 2006
Unix : bdf - free disc space
To see a report of free disc space, the "df" command is the UNIX standard. However, for HP-UX use "bdf". It's more useful.
Enjoy!
Enjoy!
Monday, May 08, 2006
Unix : httpget
Very useful utility to check if a server can access URL's programmatically i.e. without using standard IE browser port 80. Useful if you think firewalls, proxies etc. will get in the way.
Usage : httpget http://www.testsite.com
Enjoy!
Usage : httpget http://www.testsite.com
Enjoy!
Monday, May 01, 2006
Unix : Find a list of files and compile them
Very easy way to find a list of files in a directory and compile them all via a shell script without having to manually find and compile each one:
for i in $(ls *.c); do
done
This looks for a list of C files and then compiles them. You need to substitute the actual name of your compiler for the "compile" part of the script.
Enjoy!
for i in $(ls *.c); do
compile $i
done
This looks for a list of C files and then compiles them. You need to substitute the actual name of your compiler for the "compile" part of the script.
Enjoy!
Friday, April 28, 2006
Unix : Find files modified within a certain time period
So there I was trying to find where this application stored its @#$% log file.
Eventually had a brainwave and decided to search for all files recently modified.
A quick Google bought up the Find command:
Find / -mtime [+|-] value
The "+" or "-" indicates before or after e.g.
-4 indicates all files modified within the last 4 days
+4 indicates all files modified more than 4 days ago
4 indicates all files modified 4 days ago only
0 indicates all files modified in the last 24 hours.
Enjoy!
Eventually had a brainwave and decided to search for all files recently modified.
A quick Google bought up the Find command:
Find / -mtime [+|-] value
The "+" or "-" indicates before or after e.g.
-4 indicates all files modified within the last 4 days
+4 indicates all files modified more than 4 days ago
4 indicates all files modified 4 days ago only
0 indicates all files modified in the last 24 hours.
Enjoy!
Monday, April 03, 2006
Misc : Multiple IDE's
I rarely have less than 3 open at any one time covering a range of languages:
Java , C, C++ , C#, Cobol ...
What's really confusing is when you write a correct statement in the wrong language
e.g. in the Cobol IDE, I wrote:
Temp = 1;
and then you wonder why the compiler complained!
If you don't have your orientation correct, it's a puzzle because it *looks* correct. The moment you realise you are in the Cobol IDE, the penny drops.
The correct statement is of course:
Move 1 to Temp.
Enjoy!
Java , C, C++ , C#, Cobol ...
What's really confusing is when you write a correct statement in the wrong language
e.g. in the Cobol IDE, I wrote:
Temp = 1;
and then you wonder why the compiler complained!
If you don't have your orientation correct, it's a puzzle because it *looks* correct. The moment you realise you are in the Cobol IDE, the penny drops.
The correct statement is of course:
Move 1 to Temp.
Enjoy!
Friday, March 17, 2006
Misc : FTP from a browser
Most people know that you can FTP from a browser via the
ftp://
mechanism.
What most people don't realise is that you can also include the logon and password. The format is:
ftp://logon:password@site
e.g. ftp://user1:pass1@111.24.12.6
You can also set an initial directory
e.g. ftp://user1:pass1@111.24.12.6/dir1/dir2
provided that the user has the rights to access that directory.
Enjoy!
ftp://
mechanism.
What most people don't realise is that you can also include the logon and password. The format is:
ftp://logon:password@site
e.g. ftp://user1:pass1@111.24.12.6
You can also set an initial directory
e.g. ftp://user1:pass1@111.24.12.6/dir1/dir2
provided that the user has the rights to access that directory.
Enjoy!
Wednesday, March 15, 2006
.NET : Converting two ASCII bytes to one hex byte
One of the big disadvantages of tools like Visual Studio is that they hide the underlying machine operations from the user. As a result, most developers haven't a clue about hex , bit shifting etc. To those oldies who started in the assembler / DOS era, hex manipulation is something they ate / slept and breathed.
Quickly, what's 0x7e in decimal?
Waaay to slow. The answer is 126. (7 x 16) + 14.
So I'm sitting with a whole bunch of "wunderkinden" (who think they know everything)
and not one of them could figure out how to "un URL encode" in C#
i.e. convert %7F (three ASCII bytes) to 1 hex byte (0x7F).
Here's one way:
String urlEncode = "%7F";
String hString = "0123456789ABCDEF";
String sHighVal = urlEncode.Substring (1,1);
String sLowVal = urlEncode.Substring (2,1);
int iHighVal = hString.IndexOf (sHighVal);
int iLowVal = hString.IndexOf (sLowVal);
iHighVal = iHighVal << 4;
int result = iHighVal | iLowVal;
Enjoy!
Quickly, what's 0x7e in decimal?
Waaay to slow. The answer is 126. (7 x 16) + 14.
So I'm sitting with a whole bunch of "wunderkinden" (who think they know everything)
and not one of them could figure out how to "un URL encode" in C#
i.e. convert %7F (three ASCII bytes) to 1 hex byte (0x7F).
Here's one way:
String urlEncode = "%7F";
String hString = "0123456789ABCDEF";
String sHighVal = urlEncode.Substring (1,1);
String sLowVal = urlEncode.Substring (2,1);
int iHighVal = hString.IndexOf (sHighVal);
int iLowVal = hString.IndexOf (sLowVal);
iHighVal = iHighVal << 4;
int result = iHighVal | iLowVal;
Enjoy!
Thursday, March 09, 2006
Cobol : Conditional compile
This may apply only to Micro Focus.
Define a 78 level in Working Storage.
78 functionality value "yes".
Then use the $if .. $else .. $end construct,
$if functionality defined
* Conditional code xxx here.
$end
With this setup, xxx will be compiled. Now here's the trick. You would then expect that setting "functionality" to "no" would stop xxx from being compiled but no way!
You need to comment out the 78 line to achieve this.
You can also achieve this from the command line:
cob -C 'constant functionality "yes"' yyy.cbl
(Pay special attention to the use of ' and ").
Enjoy!
Define a 78 level in Working Storage.
78 functionality value "yes".
Then use the $if .. $else .. $end construct,
$if functionality defined
* Conditional code xxx here.
$end
With this setup, xxx will be compiled. Now here's the trick. You would then expect that setting "functionality" to "no" would stop xxx from being compiled but no way!
You need to comment out the 78 line to achieve this.
You can also achieve this from the command line:
cob -C 'constant functionality "yes"' yyy.cbl
(Pay special attention to the use of ' and ").
Enjoy!
Tuesday, March 07, 2006
Cobol : Trimming a field
Cobol doesn't support a trim function but you can get by by using:
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
Enjoy!
WORKING-STORAGE SECTION.
01 InputString Pic X(20).
01 TrimString Pic X(20).
01 TrimCount Pic 9(2).
PROCEDURE DIVISION.
move 'poiuytrewq ' to InputString
move zero to TrimCount
inspect function reverse (InputString) tallying TrimCount for leading space
compute TrimCount = (length of InputString) - TrimCount
move InputString (1:TrimCount) to TrimString
Enjoy!
Subscribe to:
Posts (Atom)