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

    Dec 23, 2006
    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 :) ).

  2. Headrush


    Feb 9, 2005
    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


    Jun 15, 2005
    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
    if [ -f $filename ]
    kill -$whatever $pid
    sleep $number_of_seconds
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!

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