Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 04:05 PM
10-29-2003 04:05 PM
I need to produce a file on unix for a mainframe application.
The specs for the file say that each record
of the file needs to be started with
"a delimiter of ¬ which translates to hex value of X'5F'. Each record is terminated by a 2-byte field with the hex value of x'0D25'."
What's a nice, clean solution for this?
I've toyed with bc but haven't had much success. Any thoughts? Thx in advance.
Cat
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 05:05 PM
10-29-2003 05:05 PM
Re: Hex Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 05:11 PM
10-29-2003 05:11 PM
Re: Hex Help
I'd use perl. To get 'hex' constants check out sprintf, vec anc pack. For example:
http://www.perldoc.com/perl5.8.0/pod/func/vec.html
Here is a possible solution:
perl -e 'vec($h,0,8)=0x5F; vec($t,0,16)=0x0D25; while(<>) {chop; print $h,$_,$t}' < unixfile > mainframefile
check with: od -t x1 file | head
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 05:19 PM
10-29-2003 05:19 PM
Re: Hex Help
printf("%c",95); # for the 0x5f, which is 95
printf("%c%c",13,37); # for the 0x0D25
I'm not sure what else you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 07:30 PM
10-29-2003 07:30 PM
SolutionAlso the mainframe will probably expect each hex value to be 2 chars wide, so you need a precision of 2.2 also.
ie from awk, you would use
printf("%-2.2x",95); # for the 0x5f, which is 95
printf ("THE REST OF YOUR RECORD HERE")
printf("%-2.2x%-2.2x\n",13,37); # for the 0x0D25
Hope this helps.
(BTW, I don't think bc is the way to go)
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 07:55 PM
10-29-2003 07:55 PM
Re: Hex Help
It might be a good idea to check the hex values again, because none of these values is unusual in ASCII:
hex 5F is an underscore character
hex 0D is carriage return [e.g. printf("\r")]
hex 25 is a percent character.
Also, check the order of the bytes in the 2-byte field value x'0D25'. On a big-endian machine like PA-RISC or SPARC, the first byte in a multi-byte value is the most sigificant, so a 2-byte value of 0D25 would be obtained by a byte 0D followed by a byte 25, e.g. printf("\r%%"). However, on a little-endian machine, such as 80x86, Alpha, or VAX, the first byte in a multi-byte value is the least significant, so the 2-byte value of 0D25 would be obtained by a percent character followed by a carriage return character, e.g. printf("%%\r").
Best to have a look at the records on your destination machine.
If you need to convert to EBCDIC, dd is an obvious solution. I'd have expected PERL to have an ASCII/EBCDIC converter, but a (very) quick scan of my PERL book didn't come up with anything.
Good Luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 02:55 AM
10-30-2003 02:55 AM
Re: Hex Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 03:16 AM
10-30-2003 03:16 AM
Re: Hex Help
Are you the same person as Cathy Breslow ?
Why 2 ids ?
Anyway I (or anyone - I go home in 10 minutes) can have a go at giving you "the full awk syntax", but we would need a few more clues.
Like what's your input data?
What's your output format?
Anything happen to the data in between?
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 03:23 AM
10-30-2003 03:23 AM
Re: Hex Help
I want to create a variable with these hex values because I need to insert them in several places in the file.
Cathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 03:29 AM
10-30-2003 03:29 AM
Re: Hex Help
Here's a thread that discusses this:
http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0xefcfd7d96cbad711900a0090279cd0f9%2C00.html&admit=716493758+1067531246041+28353475
I also noted that the recent Foruns upgrade mangled some of my syntax so I fikx and attach the original convert.pl script. Adding hard-coded hex values toi the output is trivially easy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2003 06:38 AM
10-30-2003 06:38 AM
Re: Hex Help
> I think Graham's solution may be the best and simplest
I'm afraid it is not. It just outputs the hex as text, not as a hex value in a character. It is much similar to: print "5F", $0, "0D25", $0;
Be sure to re-view the solution I suggested.
It has the header and tail in variables $h and $t.
Also be sure to study the comments in other replies on EBCDIC, 'normal characters' being recognized as terminators, and the endianness. (For example, in my solution you may have to swap the 0D and 25 in the string
Good luck,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2003 03:55 AM
11-06-2003 03:55 AM
Re: Hex Help
in case you haven´t got a solution yet.
Otherwise be so kind to award points to the contributors, which helped you.
Michael
#!/bin/ksh
while read TEXT
do
echo "\0137${TEXT}\015\045\c"
done < $
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2003 04:03 AM
11-06-2003 04:03 AM
Re: Hex Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2003 04:07 AM
11-06-2003 04:07 AM
Re: Hex Help
you would have to login as Cathy since that is the user, that created the post. Then you see drop down buttons with 0 to 10 points.
Click on how many points you want to award, and use the submit points button at the buttom.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2003 04:36 AM
11-06-2003 04:36 AM