Sponsored Content
Top Forums Shell Programming and Scripting Combine splitted low & high byte files into one file Post 302869973 by Chubler_XL on Thursday 31st of October 2013 04:26:06 PM
Old 10-31-2013
How about using perl:

Code:
#!/usr/bin/perl -w

open HI, $ARGV[0] || die $!;
binmode HI;
open LO, $ARGV[1] || die $!;
binmode LO;

my $hidata;
my $lowdata;

while (read(HI, $hidata, 1)) {

   read(LO, $lowdata, 1) || last;

   printf "%c%c", ord($hidata),ord($lowdata);
}
close HI;
close LO;

Eg:

Code:
$ printf "\x0\x2\x4\x6\x8\xA" > Hi
$ printf "\x1\x3\x5\x7\x9\xB" > Lo
$ ./ans.pl Hi Lo > result
$ od -t d1 result
0000000    0    1    2    3    4    5    6    7    8    9   10   11
0000014

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

malloc returning NULL if freemem high & swapmem low

Hi All, In my application malloc is returning NULL even though there is sufficient amount of free memory is available but swap memory is low. Is this possible that, if free memory is high & swap memory is low, malloc will not be able to allocate memory & return NULL ?:) Kindly look into... (5 Replies)
Discussion started by: Ritesh Kumar
5 Replies

2. UNIX for Dummies Questions & Answers

malloc returning NULL if freemem high & swapmem low (MPRAS version 3.03 )

Hi All,:) In my application malloc is returning NULL even though there is sufficient amount of free memory available but the swap memory is low. Is this possible that, if free memory is high & swap memory is low, malloc will not be able to allocate memory & return NULL ? Few details: ... (4 Replies)
Discussion started by: Ritesh Kumar
4 Replies

3. Shell Programming and Scripting

low & high values

on the file Ftp'd from the mainframe ,do we have any UNIX command to replace mainframe low and values to space or null. i tried using tr and it doesn't work ... Thanks (1 Reply)
Discussion started by: rlmadhav
1 Replies

4. Shell Programming and Scripting

Picking high and low variables in a bash script - possible?

Is it possible to have a bash script pick the highest and lowest values of four variables? I've been googling for this but haven't come up with anything. I have a script that assigns variables ($c0, $c1, $c2, and $c3) based on the coretemps from grep/sed statements of sensors. I'd like to also... (5 Replies)
Discussion started by: graysky
5 Replies

5. Shell Programming and Scripting

Split file into chunks of low & high byte

Hi guys, i have a question about spliting a binary file into 2 chunks. First chunk with all high bytes and the second one with all low bytes. What unix tools can i use? And how can this be performed? I looked in manpages of split and dd but this does not help. Thanks (2 Replies)
Discussion started by: basta
2 Replies

6. UNIX for Dummies Questions & Answers

Kernel/ user space and high/ low mem

Need some clarification on this.... 1. how are kernel/ user spaces and high/low memory related? 2. What do they all mean when i have the kernel command line as: "console=ttyS0,115200 root=/dev/sda2 rw mem=exactmap memmap=1M@0 memmap=96M@1M irqpoll" or 2. what do mem and memmap mean in... (3 Replies)
Discussion started by: dragonpoint
3 Replies

7. Shell Programming and Scripting

How to combine 2 files and output the unique & difference?

Hi Guys, I have two input files and I want to combine them and get the unique values and differences and put them into one file. See below desired output file. Inputfile1: 1111111 2222222 3333333 7860068 7860069 7860071 7860072 Inputfile2: 4444444 (4 Replies)
Discussion started by: pinpe
4 Replies

8. AIX

High Runqueue (R) LOW CPU LOW I/O Low Network Low memory usage

Hello All I have a system running AIX 61 shared uncapped partition (with 11 physical processors, 24 Virtual 72GB of Memory) . The output from NMON, vmstat show a high run queue (60+) for continous periods of time intervals, but NO paging, relatively low I/o (6000) , CPU % is 40, Low network.... (9 Replies)
Discussion started by: IL-Malti
9 Replies

9. Shell Programming and Scripting

splitting newfile.txt file and executing each splitted files

split -l $split_count newfile.txt for i in $split_files* do if test -s $workingdir/$split_files* then ./<$i.out> fi done ... (4 Replies)
Discussion started by: sanjay mn
4 Replies

10. Red Hat

High RAM usage, extremely low swapping

Hi team I have three physical servers running on Red Hat Enterprise Linux Server release 6.2 with the following memory conditions: # cat /proc/meminfo | grep -i mem MemTotal: 8062888 kB MemFree: 184540 kB Shmem: 516 kB and the following swap conditions: ... (6 Replies)
Discussion started by: hedkandi
6 Replies
guestfs-perl(3) 					      Virtualization Support						   guestfs-perl(3)

NAME
guestfs-perl - How to use libguestfs from Perl SYNOPSIS
use Sys::Guestfs; my $g = Sys::Guestfs->new (); $g->add_drive_opts ('guest.img', format => 'raw'); $g->launch (); $g->mount ('/dev/sda1', '/'); $g->touch ('/hello'); $g->shutdown (); $g->close (); DESCRIPTION
This manual page documents how to call libguestfs from the Perl programming language. This page just documents the differences from the C API and gives some examples. If you are not familiar with using libguestfs, you also need to read guestfs(3). To read the full Perl API, see Sys::Guestfs(3). ERRORS Errors from libguestfs functions turn into calls to "croak" (see Carp(3)). EXAMPLE 1: CREATE A DISK IMAGE #!/usr/bin/perl -w # Example showing how to create a disk image. use strict; use Sys::Guestfs; my $output = "disk.img"; my $g = new Sys::Guestfs (); # Create a raw-format sparse disk image, 512 MB in size. open FILE, ">$output" or die "$output: $!"; truncate FILE, 512 * 1024 * 1024 or die "$output: truncate: $!"; close FILE or die "$output: $!"; # Set the trace flag so that we can see each libguestfs call. $g->set_trace (1); # Attach the disk image to libguestfs. $g->add_drive_opts ($output, format => "raw", readonly => 0); # Run the libguestfs back-end. $g->launch (); # Get the list of devices. Because we only added one drive # above, we expect that this list should contain a single # element. my @devices = $g->list_devices (); if (@devices != 1) { die "error: expected a single device from list-devices"; } # Partition the disk as one single MBR partition. $g->part_disk ($devices[0], "mbr"); # Get the list of partitions. We expect a single element, which # is the partition we have just created. my @partitions = $g->list_partitions (); if (@partitions != 1) { die "error: expected a single partition from list-partitions"; } # Create a filesystem on the partition. $g->mkfs ("ext4", $partitions[0]); # Now mount the filesystem so that we can add files. $g->mount ($partitions[0], "/"); # Create some files and directories. $g->touch ("/empty"); my $message = "Hello, world "; $g->write ("/hello", $message); $g->mkdir ("/foo"); # This one uploads the local file /etc/resolv.conf into # the disk image. $g->upload ("/etc/resolv.conf", "/foo/resolv.conf"); # Because we wrote to the disk and we want to detect write # errors, call $g->shutdown. You don't need to do this: # $g->close will do it implicitly. $g->shutdown (); # Note also that handles are automatically closed if they are # reaped by reference counting. You only need to call close # if you want to close the handle right away. $g->close (); EXAMPLE 2: INSPECT A VIRTUAL MACHINE DISK IMAGE #!/usr/bin/perl -w # Example showing how to inspect a virtual machine disk. use strict; use Sys::Guestfs; if (@ARGV < 1) { die "usage: inspect_vm disk.img" } my $disk = $ARGV[0]; my $g = new Sys::Guestfs (); # Attach the disk image read-only to libguestfs. # You could also add an optional format => ... argument here. This is # advisable since automatic format detection is insecure. $g->add_drive_opts ($disk, readonly => 1); # Run the libguestfs back-end. $g->launch (); # Ask libguestfs to inspect for operating systems. my @roots = $g->inspect_os (); if (@roots == 0) { die "inspect_vm: no operating systems found"; } for my $root (@roots) { printf "Root device: %s ", $root; # Print basic information about the operating system. printf " Product name: %s ", $g->inspect_get_product_name ($root); printf " Version: %d.%d ", $g->inspect_get_major_version ($root), $g->inspect_get_minor_version ($root); printf " Type: %s ", $g->inspect_get_type ($root); printf " Distro: %s ", $g->inspect_get_distro ($root); # Mount up the disks, like guestfish -i. # # Sort keys by length, shortest first, so that we end up # mounting the filesystems in the correct order. my %mps = $g->inspect_get_mountpoints ($root); my @mps = sort { length $a <=> length $b } (keys %mps); for my $mp (@mps) { eval { $g->mount_ro ($mps{$mp}, $mp) }; if ($@) { print "$@ (ignored) " } } # If /etc/issue.net file exists, print up to 3 lines. my $filename = "/etc/issue.net"; if ($g->is_file ($filename)) { printf "--- %s --- ", $filename; my @lines = $g->head_n (3, $filename); print "$_ " foreach @lines; } # Unmount everything. $g->umount_all () } SEE ALSO
Sys::Guestfs(3), guestfs(3), guestfs-examples(3), guestfs-erlang(3), guestfs-java(3), guestfs-lua(3), guestfs-ocaml(3), guestfs-python(3), guestfs-recipes(1), guestfs-ruby(3), http://libguestfs.org/. AUTHORS
Richard W.M. Jones ("rjones at redhat dot com") COPYRIGHT
Copyright (C) 2011-2012 Red Hat Inc. LICENSE
This manual page contains examples which we hope you will use in your programs. The examples may be freely copied, modified and distributed for any purpose without any restrictions. BUGS
To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools When reporting a bug, please supply: o The version of libguestfs. o Where you got libguestfs (eg. which Linux distro, compiled from source, etc) o Describe the bug accurately and give a way to reproduce it. o Run libguestfs-test-tool(1) and paste the complete, unedited output into the bug report. libguestfs-1.22.6 2013-08-24 guestfs-perl(3)
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy