Need some guidance for linux programs

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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.
 
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.)
 
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
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

Top