Sponsored Content
Top Forums Shell Programming and Scripting Dont have a clue which program to use to process flying bat data Post 302499180 by Corona688 on Wednesday 23rd of February 2011 02:16:57 PM
Old 02-23-2011
Interesting. We usually don't get asked about bats around here! Smilie It would really, really help to know what system you're on. I'm writing code for junky old shells that'll take 30 lines to do what a newer one could do in 5 until you tell me you have anything better.

---------- Post updated at 01:16 PM ---------- Previous update was at 01:09 PM ----------

Code that should work in even junky old shells:
Code:
#!/bin/sh

PDATE=""
M3="" ; M2="" ; M1="" ; M0=""

while IFS="," read DAY TIME BELFRY
do
        if [ "$PDATE" != "${DAY},${TIME}" ]
        then
                PDATE="${DAY},${TIME}"
                M0="${BELFRY}"
                M1=""
                M2=""
                M3=""
                continue
        fi

        M3="${M2}" ; M2="${M1}" ; M1="${M0}"
        M0="${BELFRY}"

        if [ "${M3},${M2},${M1},${M0}" = "0,1,1,1,0,0,1,0" ]
        then
                echo "${DAY},${TIME} Transit B"
        elif [ "${M3},${M2},${M1},${M0}" = "1,1,0,1,1,0,0,0" ]
        then
                echo "${DAY},${TIME} Transit A"
        fi
done

Code:
$ cat batmon.dat
20/01/2011,10:10,1,1
20/01/2011,10:10,0,1
20/01/2011,10:10,1,0
20/01/2011,10:10,0,0
21/01/2011,10:15,0,1
21/01/2011,10:15,1,1
21/01/2011,10:15,0,0
21/01/2011,10:15,1,0
$ ./batmon.sh < batmon.dat
20/01/2011,10:10 Transit A
21/01/2011,10:15 Transit B
$

It assumes that a bat takes less than a minute to fly through the two infrared beams Smilie Usually a good assumption but there's the odd chance that a bat might hit the beam at 11:59:59.99999, and hit the second at 12:00:00.000000....
 

9 More Discussions You Might Find Interesting

1. HP-UX

IO by Process/program

HI there, I'm trying to find a way of showing the IO's performed by individual programs. Number of reads/writes IO time that kind of thing. Anybody know of any way to show this information. Free little downloads that kind of thing? Cheers Phil (2 Replies)
Discussion started by: cpiuk
2 Replies

2. HP-UX

get program name give a process id

Hi , I have query regarding to get a program name given a pid in HP-Ux . give procees id ( PID) i would like to retrieve the process/program through a C program ? my input to c program will be will be pid and i would like to know what is process name /program name . Many Thanks ... (1 Reply)
Discussion started by: naren_chella
1 Replies

3. Programming

Getting process info in a program

Hi, I am wondering if there is a way to find out in a C software program if a particular process is running without having to write a file. In the past, I have been using the system command to execute a pgrep and output the info to a file. Then the C program reads the file to make the... (1 Reply)
Discussion started by: herbmiller
1 Replies

4. Programming

How to start a process in linux using C program??

I have a set of attributes such as group id,group name,etc related to a linux process. Iwant to know how to start a process in linux using C program.Plz do help me. (3 Replies)
Discussion started by: vigneshinbox
3 Replies

5. Programming

Process creation in Unix with C Program

Hi, can somebody please help me regarding this? How can i print parent's PID from child's and vice versa. I have tried with getpid() & ngetppid() function but it is not giving me the correct data. The logic i used is: if (pid == 0) { getpid() : Chil'd PID getppid():... (1 Reply)
Discussion started by: dsudipta
1 Replies

6. UNIX for Dummies Questions & Answers

defunct process occuring in a particular program

All, I am getting a wired scenario, Not all times but some times i am getting the defunct process for a program. If i rerun the same program it is working fine.This defunct scenario is not occuring often. And this is happening only for the one program in my system that to sometimes Can you... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

7. Shell Programming and Scripting

dont have a clue again- flying bat data new logger

hi, this is related to this thread https://www.unix.com/shell-programming-scripting/154822-dont-have-clue-program-use-process-flying-bat-data.html using another type of logger (ipcas ipether232) which produces csv data but not seperated into differnt folders. I need to work out how to get... (2 Replies)
Discussion started by: cmp260
2 Replies

8. Shell Programming and Scripting

How can I get parent process program name?

Hi: I have 2 script on AIX server. The child script is called by parent script. For example: The parent script full name is /home/op/def/parent.spt, which calls /home/op/abc/child.spt I want to get the parent program name with full path name (i.e. /home/op/def/parent.spt), in... (3 Replies)
Discussion started by: cstsang
3 Replies

9. Shell Programming and Scripting

I dont want to exit the program by ctrl + c

Hey , guys I am new to shell programing ,, so need a help from you guys ... I have to write a shell script that accepts file name or directory name from the user if it is a directory then throw an error if it is a file then give the user two options . 1.overwrite the content 2.append the... (2 Replies)
Discussion started by: coolashu
2 Replies
mconv_stream_converter(3m17n)					 The m17n Library				     mconv_stream_converter(3m17n)

NAME
mconv_stream_converter - Create a code converter bound to a stream. SYNOPSIS
MConverter* mconv_stream_converter (MSymbol name, FILE * fp) DESCRIPTION
Create a code converter bound to a stream. The mconv_stream_converter() function creates a pointer to a code converter for coding system name. The code converter is bound to stream fp. Subsequent decodings and encodings are done to/from this stream. name can be Mnil. In this case, a coding system associated with the current locale (LC_CTYPE) is used. RETURN VALUE
If the operation was successful, mconv_stream_converter() returns the created code converter. Otherwise it returns NULL and assigns an error code to the external variable merror_code. ERRORS
MERROR_SYMBOL, MERROR_CODING SEE ALSO
mconv_buffer_converter() COPYRIGHT
Copyright (C) 2001 Information-technology Promotion Agency (IPA) Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>. Version 1.6.2 12 Jan 2011 mconv_stream_converter(3m17n)
All times are GMT -4. The time now is 03:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy