Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Linux and Unix
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel firefox hard drive hardware internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery router safe mode screen slow sound spyware tdlwsp.dll trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Need some guidance for linux programs

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
Boylett's Avatar
Computer Specs
Member with 52 posts.
 
Join Date: Dec 2006
Experience: Intermediate
02-Feb-2007, 02:29 PM #1
Question Need some guidance for linux programs
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.
Headrush's Avatar
Senior Member with 482 posts.
 
Join Date: Feb 2005
Experience: Advanced
03-Feb-2007, 12:42 AM #2
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.)
AGCurry's Avatar
Senior Member with 431 posts.
 
Join Date: Jun 2005
Location: Kansas City area
Experience: advanced but learning
03-Feb-2007, 10:12 PM #3
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
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 05:46 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.