Comp-3 conversion possible with Shell Scripting or PERL?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comp-3 conversion possible with Shell Scripting or PERL?
# 8  
Old 04-14-2005
Quote:
Originally Posted by Perderabo
With packed decimal, any decimal point is assumed. It is not stored in the data.
Per, need some more help. Noting your quote above, we have a field that is signed (see below) that I need to put into comp-3 format. Any ideas? I know you said the decimal is implied, but what about handling a positive or negative number?

+000000000050408

or

-000086214050408
# 9  
Old 04-14-2005
Take another look. The script handles negative numbers.
# 10  
Old 04-19-2005
Oops, sorry about that. Was so concerned about the packing piece of the puzzle that I overlooked the negative handling. One thing in your script has me confused. I did a man on "od" and there is no "-t" option. What is this line doing:

print -n ${output[o]} | od -t x1

Also, in your script, is it the "$result" variable that is ultimately holding the packed output? With all of the outputting in different formats and display messages (and my "light" UNIX coding experience), I got a little disoriented.
# 11  
Old 04-19-2005
Here is the AIX man page for od. I see the -t option which is required for posix compatability.

Look at the end of my script:
Code:
#
#  output the packed decimal to prove it worked

olength=${#output[*]}
o=0
while ((o <= olength)) ; do
        print -n ${output[o]} | od -t x1
        ((o=o+1))
done

The output is in "output".
# 12  
Old 08-03-2006
Ksh to Convert Ascii to Comp-3

I have tried using the sample script, but have a problem when trying to pack a number that has concurrent zeroes. The result of packing to two zeroes results in a null hex value, that cannot be printed. Is there any way to deal with this?

Thanks for the info.
# 13  
Old 02-22-2008
Tools What about the other direction? Comp-3 to ASCII?

I found this thread showing how to make a Comp-3 field. However, I have to accomplish the opposite:
Read a count variable stored as Comp-3 telling me how many records to expect. Then, report back if I received all of the records in an ftp.

So, any ideas or past scripts, on how to convert a signed Comp-3 field?

Thanks.
# 14  
Old 02-23-2008
The main problem is that comp-3 is just binary data. Thoughout the thread I am doing stuff like "print -n ${output[o]} | od -t x1" because the data is binary. This is why coutulea's question made no sense. So where is your data? How do you propose to make it available to a shell script? If you can isolate the comp-3 field and pump it through od and read the out of od into a script, it probably can be done.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required for Oracle database shutdown script conversion from shell to perl

Please tell me how to convert below program from shell script to perl. Same commands need to use in shutdown, just need program help for startup. export ORACLE_BASE=/home/oracle1 lsnrctl start lndb1 sqlplus '/ as sysdba' startup; (2 Replies)
Discussion started by: learnbash
2 Replies

2. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

3. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

4. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

5. Shell Programming and Scripting

Conversion from Perl to Shell scripting

Hai ! I am doing a research on Bioinformatics and a part of the code in perl have to be converted to shell scripting. I am new to shell programming. Pls. kindly help me to convert this code to shell script though it is somewhat lengthy. PLS KINDLY HELP ME. THANKS IN ADVANCE. my @FreeEnergy =... (1 Reply)
Discussion started by: kswapnadevi
1 Replies

6. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

7. Shell Programming and Scripting

Linux/Unix shell scripting vs Perl

Hi, I have general question: i have good working Perl script with .pl extension, and now I have to migrate all to another Linux box, and I was told that I can use only shell scripting, so I'm not sure how different those two things are, will it work without any changes . Is there anything smart I... (6 Replies)
Discussion started by: trento17
6 Replies

8. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

9. Shell Programming and Scripting

Should I use PERL or Shell scripting?

Hello, I have done some BASIC shell scripting/PERL scripting before so I am familiar with the languages. I am not really sure which one would lend itself better to the application I have to write. I am required to scan the message logs for possible break in attempts. If I use shell scripting... (3 Replies)
Discussion started by: mojoman
3 Replies

10. UNIX for Dummies Questions & Answers

Another bash shell to perl conversion

Hello everyone. I am new to linux and need help again. I need help converting this bash shell to linux: for i in `ls -l *.txt` do `./cnvidtf.pl $i` `curl -u login:pswd --disable-espv -T loadfile.seq ftp://11.1.11.1` `mysql -u login -h 11.1.11.1 -ppswd < lddocs.sql` done Thanks! Any help... (6 Replies)
Discussion started by: freak
6 Replies
Login or Register to Ask a Question