Sponsored Content
Top Forums Programming How can I send data to my C converter? Post 302598425 by ws6transam on Tuesday 14th of February 2012 01:07:53 PM
Old 02-14-2012
How can I send data to my C converter?

Hello,
I have a directory structure of seismic files that are stored within about 1000 different directories. The directory structure is typically no more than two levels deep, and they are organized by station name and disc name. Each disc name folder contains a text file called 'vdaq.txt' that I need to convert. Thus, there about a thousand of these vdaq.txt files that I want to import into my C program which converts the file into it's required new binary format.

I can hand-type this command from a command line window:

vdaqconv ~/Documents/Sample_data/SEY08N13/vdaq.txt

and the converter will successfully recognize the file name and directory, do the conversion, and place the converted binary file back into the appropriate directory (in this case, ~/Documents/Sample_data/SEY08N13/).

I can also search for all instances of the file vdaq.txt by using the following command from the top of the directory structure:

find . -name 'vdaq.txt'

The result is a nice long table of all the subdirectories that contain the target file. The information found within the file changes, based on time and station location so I cannot jsut 'blanket copy' over the whole dataset; Each one must be individually converted .

I have tried to pipe the output from the find command into the converter thus:

find . -name 'vdaq.txt' | vdaqconv

However the result is that the converter appears to ignore the output from the find command.

How can I get the converter to process each line from the find command?

I have searched the forums, and probably haven't figured out the appropriate terms to find my answers. Could someone point me in the right direction? - Thanks.

-Daniel

---------- Post updated at 01:07 PM ---------- Previous update was at 11:29 AM ----------

..back from lunch with additional information.
I guess what I was looking for was the question:

How do I use the input from the find command as a series of command-line arguments for a C-code program?"

My sample output from the find command: ( I generated this snippet from the greater subset by using the >> command to output the find results into a sample text file.)
Quote:

./SEY/SEY08N13/vdaq.txt
./SEY/SEY04N23/vdaq.txt
./SEY/SEY07N33/vdaq.txt
./SEY/SEY03N42/vdaq.txt
./SEY/SEY04N29/vdaq.txt
./SEY/SEY03N44/vdaq.txt
./SEY/SEY07N32/vdaq.txt
./SEY/SEY04N33/vdaq.txt
./SEY/SEY07N36/vdaq.txt
./SEY/SEY04N26/vdaq.txt
./SEY/SEY04N01/vdaq.txt
./SEY/SEY07N13/vdaq.txt
./SUUS/SUUS06N09/vdaq.txt
./SUUS/SUUS04N05/vdaq.txt
./SUUS/SUUS04N23/vdaq.txt
./ULN/ULN06N02/20060703/vdaq.txt
./ULN/ULN06N02/20050802/vdaq.txt
./ULN/ULN06N02/20060721/vdaq.txt
./ULN/ULN06N03/20060727/vdaq.txt
./ULN/ULN06N01/vdaq.txt
./GOLD/GOLD04N09/vdaq.txt
./GOLD/GOLD03N01/vdaq.txt
./AND1/AND103N99/AND-1/vdaq.txt
./MGD/MGD06N32/vdaq.txt
I want to output this data into a program that accepts one command line argument representing the file name that will be converted from text format into binary format.

--Program code snippet:--
Quote:
int main(int argc, char **argv)
{

FILE *ASCII_Headerfile, *BIN_Headerfile;

/* Declare local variables */

int fhdr=0,len=0,Chval_type=0, Cnt=0, Arrayval = 1;
hdr.unknown = 0; /* There is a variable that has unknown meaning found within all hdr sample files. */
memset(spath,0,sizeof(spath)); /* clear the path of all unknowns */
if ( argc!=2){ /* No single argument is present. Assume file exists in the working directory. */
strncpy(ASCIIfile,"vdaq.txt",8);
printf(" Using default directory and default name vdaq.txt \n");
strncpy(spath,"./",2);
display_usage();

}
else {
/*An assumed file name is present in command line. Strip path and build the header filename */
strncpy(ASCIIfile,argv[1],strlen(argv[1]));
findpath();
}
strcat(spath,"viseis.hdr");
printf("The path is stored as '%s'\n",spath);

printf( "Reading file '%s'\n",ASCIIfile);


ASCII_Headerfile = fopen(ASCIIfile,"r"); /* Open the ascii file */
.
.
. extra program stuff snipped out of here.
.
.
So, the question is, how to I interface the two together? I would like to automate the conversion such that the output of the find command continually calls the converter whenever it finds another copy of the vdaq.txt file within the directory structure.
 

10 More Discussions You Might Find Interesting

1. Programming

Send flaged data ..

Hello ! I'm writing a chat program , and I have a curiozity. I'm curently using two ports ( sockets ) for client - server interconections. One socket is used for ordinary ( normal ) data ( Ex : data on main-chat ) , and the another ( two socket ) is used to send management data : ( Ex... (0 Replies)
Discussion started by: !_30
0 Replies

2. Shell Programming and Scripting

Filter data and send email

Need script....We get sar file sa15 with 7 days data which gets appended.. we want filter and parse the outptu such that we should filter only last 48 hours data and then email it to out team. we read -- sar -f sa15 Please help me with the script either by use sar itself or even sar and awk... (10 Replies)
Discussion started by: noorm
10 Replies

3. Shell Programming and Scripting

Send data to standard input

Hello, I'm writting a korn script that executes a daemon in a remote server. The problem is that daemon doesn't go background until it receives an enter from the standard input, and it maintains the rsh opened until it get it. I'm looking for the best (efficient and elegant) way to do send the... (3 Replies)
Discussion started by: nefeli
3 Replies

4. Shell Programming and Scripting

send data with Perl

Hello! I want to sent data (pictures: pic.jpg or textfiles) to a server. The pictures should be stored in \my_pictures\beautiful_images. How can I do it with Perl? I think, that I should start with a socket?? Do you have a tutorial or a site, where I can read about it? I use the IDE Padre /... (1 Reply)
Discussion started by: la_dy82
1 Replies

5. Programming

sockets - can you send data while waiting on select()

Hey guys, Is it possible to have a worker thread send data out a TCP connection while another thread is waiting using using select() on that same connection? If not, then what is the correct way to maintain a connection, react to incoming data, and send data over a TCP connection? Thanks... (16 Replies)
Discussion started by: scubanarc
16 Replies

6. Infrastructure Monitoring

Send statistical data via SNMP

I am working on a SunOS 5.10 Generic_142900-03 sun4v sparc SUNW,Netra-T2000 With this command: (Unix based cronjob) tail -1 FSC-xxxxxxxxx.stat | nawk -F, '{print $2}' I want to send the numeric output of this command from a statistical file which is updating constantly via SNMPv2 every 1... (4 Replies)
Discussion started by: thinktank
4 Replies

7. Shell Programming and Scripting

To send a mail when the data in a folder changes

Hi All, i have a folder "fold" which will mostly have a date( like 1/2/2013 -a single date alone .whenever the date changes i shoud get a mail. could someone help me with this. (4 Replies)
Discussion started by: mahesh300182
4 Replies

8. Shell Programming and Scripting

Take Data From a table and send it through mail

Hi can anyone help me in writing a code for taking data from a table and need to send that data through mail using mail -x command.. (3 Replies)
Discussion started by: ginrkf
3 Replies

9. IP Networking

Packetize data to send it over tcp sockets

Hello All, I am very new to socket programming and client server architecture. I have to write a client which will send some data to server and server will display it on its console. I am ready with both client and server but my problem is with packetizing of data -- I have... (1 Reply)
Discussion started by: anand.shah
1 Replies

10. Programming

UNIX C Send data to PHP

Helo, i try send data from Unix to PHP. What is the correctly way to do this ? i try: c char command ; sprintf(command , "php import.php %s",my_vars); system(command ); php $my_data = @ $argv; this work, but i am not sure that is the right way. an the special chargers are not in... (1 Reply)
Discussion started by: freaky4552
1 Replies
All times are GMT -4. The time now is 02:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy