Sponsored Content
Top Forums Shell Programming and Scripting Bash equivalent of perl's pack function ? Post 302258569 by jim mcnamara on Friday 14th of November 2008 10:23:26 PM
Old 11-14-2008
There is no pack function, but you can:
Code:
# an array
newvar="${array[*]}"
# some variables
newvar="$a $var2 $somevarname"

Is this what you need?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl + pack() + spaceing question

ok guys and gals at the moment i am perplexed (prolly cuz i been looking at it to long) but here it is. OS: sol8 perlver: 5.8.0 shell: ksh answer must be in perl!! issue: when i use pack() it packs the data at the front of the requested field space. normally it wouldnt be a problem if... (1 Reply)
Discussion started by: Optimus_P
1 Replies

2. Shell Programming and Scripting

Perl help!! (pack()?)

Hello everyone. I wrote a perl script to get the two answers from a value: x. By this, I want to do sqrt($x) in different precision. #!/usr/bin/perl print "Input the initial value x:\n"; chomp($x=<STDIN>); $comp=sqrt($x); $float_value=pack("f", $comp); $double_value=pack("d", $comp);... (2 Replies)
Discussion started by: Euler04
2 Replies

3. Programming

equivalent function for wherey( ) ??

what is the equivalent function for wherey( ) ?? That is to return the current column position? (2 Replies)
Discussion started by: rockgal
2 Replies

4. Shell Programming and Scripting

perl-like split function for bash?

Hi! I'm doing bash shell scripting and would like to know if bash had something similar to perl's split function? Ultimately, I want to split two strings (delimeter = '.') and compare each of their values. Thus, I figured putting them in an array would be easiest. So i.e.: String 1:... (5 Replies)
Discussion started by: eur0dad
5 Replies

5. UNIX for Dummies Questions & Answers

perl pack and unpack commands

I have a file that contains user id and corresponding password. Lets say password is "help". The below command will create a hex value for string "help". perl -e 'print unpack "H*","help"' So now password is in encoded format. Then I decoded it in the script where am fetching the... (1 Reply)
Discussion started by: max_payne1234
1 Replies

6. Shell Programming and Scripting

Invoke Perl function from Bash ?

Is it possible to invoke a perl function from a bash script ? There are existing perl scripts with many functions that I want to reuse from a more recent script written in bash. Hence the question. (1 Reply)
Discussion started by: NewDeb
1 Replies

7. Shell Programming and Scripting

Regular expression matching in BASH (equivalent of =~ in Perl)

In Perl I can write a condition that evaluates a match expression like this: if ($foo =~ /^bar/) { do blah blah blah } How do I write this in shell? What I need to know is what operator do I use? The '=~' doesn't seem to fit. I've tried different operators, I browsed the man page for... (3 Replies)
Discussion started by: indiana_tas
3 Replies

8. UNIX for Dummies Questions & Answers

perl pack and unpack commands

I am using pack/unpack to encyrpt a file. syntax is below #!/bin/sh encrypt=`perl -e 'print unpack "H*","yourpassword"'` - echo $encrypt >/file/to/store/encrypted/password pass=`cat /file/to/store/encrypted/password` decrypt=`perl -e 'print pack "H*",$pass'` ... (2 Replies)
Discussion started by: erinlomo
2 Replies

9. Shell Programming and Scripting

Pack and unpack localtime in perl script

Hi I have a code like this: sub WriteEbcdicHeader { my $Htimestamp=localtime();#i need to pack and unpack this my $eheaderline = $Htimestamp; #packing has to be done here #unpacking has to be done after packing print $EOUTFILE return $eheaderline; } sub WriteEbcdicTrailer { ... (5 Replies)
Discussion started by: rbathena
5 Replies

10. Shell Programming and Scripting

Equivalent to Perl's and Bash's "=~" Operator?

Hello All, Alright, so this is driving me absolutely insane. I can't seem to find this ANYWHERE... I've tried every combination and synonym I can think of for this trying to search Google. What is the Expect/Tcl equivalent to Perl and Bash's "=~" operator, (i.e. the "contains" operator).... (2 Replies)
Discussion started by: mrm5102
2 Replies
table: Helps you implement a table.(3)			     Library Functions Manual			    table: Helps you implement a table.(3)

NAME
table: Helps you implement a table. - This handler helps you implement a table by doing some of the processing for you. More... Modules table_iterator: The table iterator helper is designed to simplify the task of writing a table handler for the net-snmp agent when the data being accessed is not in an oid sorted form and must be accessed externally. Functionally, it is a specialized version of the more generic table helper but easies the burden of GETNEXT processing by manually looping through all the data indexes retrieved through function calls which should be supplied by the module that wishes help. table_data: Helps you implement a table with datamatted storage. This helper helps you implement a table where all the indexes are expected to be stored within the agent itself and not in some external storage location. table_array: Helps you implement a table when data can be stored locally. The data is stored in a sorted array, using a binary search for lookups. The table_array handler is used (automatically) in conjuntion with the table handler. Functions netsnmp_mib_handler * netsnmp_get_table_handler (netsnmp_table_registration_info *tabreq) Given a netsnmp_table_registration_info object, creates a table handler. int netsnmp_register_table (netsnmp_handler_registration *reginfo, netsnmp_table_registration_info *tabreq) creates a table handler given the netsnmp_table_registration_info object, inserts it into the request chain and then calls netsnmp_register_handler() to register the table into the agent. netsnmp_table_request_info * netsnmp_extract_table_info (netsnmp_request_info *request) extracts the processed table information from a given request. netsnmp_table_registration_info * netsnmp_find_table_registration_info (netsnmp_handler_registration *reginfo) extracts the registered netsnmp_table_registration_info object from a netsnmp_handler_registration object. int table_helper_handler (netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) implements the table helper handler. int netsnmp_table_build_result (netsnmp_handler_registration *reginfo, netsnmp_request_info *reqinfo, netsnmp_table_request_info *table_info, u_char type, u_char *result, size_t result_len) Builds the result to be returned to the agent given the table information. int netsnmp_table_build_oid (netsnmp_handler_registration *reginfo, netsnmp_request_info *reqinfo, netsnmp_table_request_info *table_info) given a registration info object, a request object and the table info object it builds the request->requestvb->name oid from the index values and column information found in the table_info object. int netsnmp_table_build_oid_from_index (netsnmp_handler_registration *reginfo, netsnmp_request_info *reqinfo, netsnmp_table_request_info *table_info) Builds an oid from index information. int netsnmp_update_variable_list_from_index (netsnmp_table_request_info *tri) parses an OID into table indexses. int netsnmp_update_indexes_from_variable_list (netsnmp_table_request_info *tri) builds an oid given a set of indexes. int netsnmp_check_getnext_reply (netsnmp_request_info *request, oid *prefix, size_t prefix_len, netsnmp_variable_list *newvar, netsnmp_variable_list **outvar) checks the original request against the current data being passed in if its greater than the request oid but less than the current valid return, set the current valid return to the new value. DETAILED DESCRIPTION
This handler helps you implement a table by doing some of the processing for you. This handler truly shows the power of the new handler mechanism. By creating a table handler and injecting it into your calling chain, or by using the netsnmp_register_table() function to register your table, you get access to some pre-parsed information. Specifically, the table handler pulls out the column number and indexes from the request oid so that you don't have to do the complex work to do that parsing within your own code. To do this, the table handler needs to know up front how your table is structured. To inform it about this, you fill in a table_registeration_info structure that is passed to the table handler. It contains the asn index types for the table as well as the minimum and maximum column that should be used. FUNCTION DOCUMENTATION
int netsnmp_check_getnext_reply (netsnmp_request_info * request, oid * prefix, size_t prefix_len, netsnmp_variable_list * newvar, netsnmp_variable_list ** outvar) checks the original request against the current data being passed in if its greater than the request oid but less than the current valid return, set the current valid return to the new value. returns 1 if outvar was replaced with the oid from newvar (success). returns 0 if not. Definition at line 630 of file table.c. netsnmp_table_request_info* netsnmp_extract_table_info (netsnmp_request_info * request) [inline] extracts the processed table information from a given request. call this from subhandlers on a request to extract the processed netsnmp_request_info information. The resulting information includes the index values and the column number. Definition at line 94 of file table.c. Referenced by netsnmp_set_data_cache(), netsnmp_table_data_helper_handler(), and netsnmp_table_data_set_helper_handler(). netsnmp_table_registration_info* netsnmp_find_table_registration_info (netsnmp_handler_registration * reginfo) extracts the registered netsnmp_table_registration_info object from a netsnmp_handler_registration object. Definition at line 103 of file table.c. Referenced by netsnmp_table_data_helper_handler(). netsnmp_mib_handler* netsnmp_get_table_handler (netsnmp_table_registration_info * tabreq) Given a netsnmp_table_registration_info object, creates a table handler. You can use this table handler by injecting it into a calling chain. When the handler gets called, it'll do processing and store it's information into the request->parent_data structure. Definition at line 58 of file table.c. Referenced by netsnmp_register_table(). int netsnmp_register_table (netsnmp_handler_registration * reginfo, netsnmp_table_registration_info * tabreq) creates a table handler given the netsnmp_table_registration_info object, inserts it into the request chain and then calls netsnmp_register_handler() to register the table into the agent. Definition at line 81 of file table.c. Referenced by netsnmp_register_table_data(), and netsnmp_table_container_register(). int netsnmp_table_build_oid (netsnmp_handler_registration * reginfo, netsnmp_request_info * reqinfo, netsnmp_table_request_info * table_info) given a registration info object, a request object and the table info object it builds the request->requestvb->name oid from the index values and column information found in the table_info object. Definition at line 548 of file table.c. Referenced by netsnmp_table_build_result(). int netsnmp_table_build_oid_from_index (netsnmp_handler_registration * reginfo, netsnmp_request_info * reqinfo, netsnmp_table_request_info * table_info) Builds an oid from index information. Definition at line 574 of file table.c. int netsnmp_table_build_result (netsnmp_handler_registration * reginfo, netsnmp_request_info * reqinfo, netsnmp_table_request_info * table_info, u_char type, u_char * result, size_t result_len) Builds the result to be returned to the agent given the table information. Use this function to return results from lowel level handlers to the agent. It takes care of building the proper resulting oid (containing proper indexing) and inserts the result value into the returning varbind. Definition at line 515 of file table.c. int netsnmp_update_indexes_from_variable_list (netsnmp_table_request_info * tri) builds an oid given a set of indexes. Definition at line 612 of file table.c. int netsnmp_update_variable_list_from_index (netsnmp_table_request_info * tri) parses an OID into table indexses. Definition at line 601 of file table.c. int table_helper_handler (netsnmp_mib_handler * handler, netsnmp_handler_registration * reginfo, netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests) implements the table helper handler. Definition at line 111 of file table.c. net-snmp 5 Oct 2002 table: Helps you implement a table.(3)
All times are GMT -4. The time now is 04:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy