1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Need some guidance for linux programs

Discussion in 'Linux and Unix' started by Boylett, Feb 2, 2007.

Thread Status:
Not open for further replies.
  1. Boylett

    Boylett Thread Starter

    Joined:
    Dec 23, 2006
    Messages:
    55
    Hello,
    I would like to have a program which runs in Linux that checks if a file exists, if it does, open a socket and send whats in it to another program, then delete the file.
    Then the program it sends it to writes the information it got to another file.

    I would just like to know what things are capable of doing this, and what scripting language i would need to use (preferably an easy one :) ).

    thx.
     
  2. Headrush

    Headrush

    Joined:
    Feb 9, 2005
    Messages:
    2,609
    This could be done easily in BASH.

    Can you be more specific on what your current programming skills are, and what the exact programs are?
    (Whether the receiving application accepts data from the STDIO stream is important.)
     
  3. AGCurry

    AGCurry

    Joined:
    Jun 15, 2005
    Messages:
    431
    What you describe as what needs to happen does not justify the complexity of what you want to do, unless the second program is running all the time anyway.

    If you can get the process ID of the second program (which, as I said, has to be running already), a signal can be sent to it using shell's "kill" command. Then, the program that receives that signal (using the "trap" command) can take the steps needed to read the file that was found, write its content to another file, and delete it.

    If you really want to use sockets, I think a C program (or maybe perl? does perl have a sockets library?) might be the ticket.

    Otherwise, in the shell it's as simple as


    while true
    do
    if [ -f $filename ]
    then
    kill -$whatever $pid
    fi
    sleep $number_of_seconds
    done
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/540534

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice