Programming :: Detect Opening Of A File Using A C Program?
Jul 19, 2011
how to detect if a file is being opened by any application so that i can block it just before opening it... Actually i am working on android and using iNotify in JNI to detect the OPENING of a file...but the file is getting opened before the iNotify detects it..and therefore its displaying the contents of the file unmodified .. The actual requirement is that if anyone is trying to open the file it should be modified by my program and then the modified file should be opened.
View 10 Replies
ADVERTISEMENT
Jan 24, 2009
I'm looking for a way to detect whether or not a program has been called from pipe, e.g.
Code:
whatever | my_program
versus simply just being exectuated directly:
Code:
my_program
Why? In the first case, I want to run the program non-interactively, and in the latter case I want to print out user-friendly messages. I've been thinking along the lines of some check I haven't yet found, like:
Code:
if( stream_buffer_is_not_empty() )
print_interactive_messages();
View 1 Replies
View Related
Mar 15, 2011
I have a .png file and I didn't know which program I had to type to use it what could I do to find out?
View 8 Replies
View Related
Mar 11, 2009
write a C program to detect whether the Ethernet cable is plugged or unplugged. I found out by using a command "nm-tool" in Linux terminal will show me whether a Ethernet cable is plugged or not. If Ethernet cable is plugged, in the device part of eth0, the Hardware Link of Wired Settings will indicate a "yes" and "no" if no Ethernet cable. Hence, in my previous code, I use one function called popen to read the state as shown below:
PHP Code:
[code]....
However, now my project wish to not use the NetworkManager (where the "nm-tool" command comes from). And this gives me trouble to detect the Ethernet cable. So is there any other method for me to detect the Ethernet cable in C programming?
View 8 Replies
View Related
Mar 3, 2009
I have custom software that writes to a sensitive large file when the user does something. I would like to make backup copies of The file that gets written to, but if I make a gzip of the file at the same time someone is changing something, it will corrupt the backup because some of the data will be missing, as its backed up during being written to.
a) Is there a way to detect if a file is currently being accessed/written to?
That way if its currently being accessed, I can just make the script wait until its done and then finally back it up.
b) Instead of backing up the large file while it has potential to get written to, would it be better to make a copy of the file first, then gzip the copy? This idea comes from the fact that gzipping the original takes 5-10 seconds, whereas making a copy only takes 1-2 seconds. The less time, the less chance of corruption.
c) Is there anyway to freeze a program or a file to stop it from being written to for an amount of time?
With a, b, and c together. The best solution I have to my problem would be a script that first detects rather the file is being accessed. If not, it would then freeze the file/program and then make a quick copy of it. Once the copy is created, it will unfreeze the original file/program and then go about gzipping the copy.
View 3 Replies
View Related
Sep 23, 2009
i wanted to capture the stdout and stdin of a child process within a parent so that any output of child is sent to the parent and any input taken from the parent. code is simple enough and i have followed all code guidlines on the internet (some guidlines do differ also) my select call either hangs if i do not give a tmeout and with a timeout it returns 0 descriptors to be written to or read from:
below is the simple code for parent:
int main(void)
{
int outfd[2];
int infd[2];
[code].....
why select hangs without a timeout ... why can it not detect that the pipe is write ready i.e parent can write to it ... if it does not detect tha read pipe as having data...
View 5 Replies
View Related
Jan 26, 2011
opening a text file from glade interface.how?using c code
View 1 Replies
View Related
Apr 29, 2010
I am a beginner at programming and have been given an assignment by my professor. Its a text file with lines of varying lengths. All I have to do is write a code to open the file and see the output in an excel sheet. Have been asked to use C/C++ or visual basic
View 5 Replies
View Related
Apr 14, 2011
I have to read files from a linux server. When I copy a file I receivce just a portion of the file I expected if the process generationg ths file is still writing it.
I read the file from a java apllication using SSH/SFTP. How can I detect if the file is still used by the writing process ?
View 4 Replies
View Related
Jan 15, 2010
Ok so Basically i have 2 questions
1. i know how to create a file with c++ using but is there a way to save it to a specific location on your computer with windows and linux
Code:
2. i need to know how to run/execute/open a file in a c++ program im using and its not working
Code:
View 4 Replies
View Related
Oct 4, 2010
Its my first post in here so please be patient I am trying to use regex in perl script to detect allowed words from the file and then print output to the screen.
As an example : I have text file with orders and returns :
Item2-SKU-2-11.08.2010-online
Item3-SKU-3-11.09.2010-return
Item4-SKU-4-11.09.2010-store
My question: is it possible to make sure that i am ony outputing to the screen orders based on few conditions like Item,order form e.g. online.And is it possible to have multiple matches (Item2 only diplay if ordered online etc)
View 1 Replies
View Related
Nov 11, 2010
i want to make a program to write the result of access to a file ,i mean for example a user wants to (open,delete,edit)a file but if he has no access to this file ,something write to a log file.so after that i can check which user got access denied by accessing to which file.or if any tools available that can do this?or if there is any built in log access file that record the permission denied to files?
View 4 Replies
View Related
Mar 14, 2009
i wanted to know how can I pars a xml file (read data from xml file) and from C program.is there any function to do this for me in C.
View 1 Replies
View Related
Mar 7, 2010
An error occured during running a code. I've made run configurations properly and I've chosen GNU Elf parser,Elf parser, Mach-O parser and Cygwin PE parser as a binary parser. Eclipse CDT can not find any error in the code and code runs in terminal properly. Here are the code:
Code:
/*
* pmutex.c
*
* Created on: Mar 7, 2010
*/
#include <stdio.h>
[Code]...
Eclipse denies to run it.I've made an investigation over the eclipse.org, but I can not find any solution.
View 2 Replies
View Related
Jun 26, 2011
I have the following problem. I call a C++ program from a Java servlet by using Runtime exec. The OS is ubuntu and I use Netbeans 7.0 with Glassfish 3.1 web server.The program executes but it does not open and write into a specified file in a specified folder. The same C++ program compiled under Windows opens and writes this file.How can I solve this problem in Linux?
View 2 Replies
View Related
Mar 18, 2011
I am learning Linux daemon programming and write a simple daemon program. The issue is no data is written to the log file (/var/tmp/simpledeamon.log) though the file is successfully created (it's file size is zero from ls -l output). Could someone kindly point out the error in my program,The code is based on the Devin Watson's article at Here is the code:
// simplydaemon.cpp
// A simple Linux daemon.
#include <sys/types.h>
[code]...
View 2 Replies
View Related
Sep 3, 2010
i create a file with .py extension and run it then on windows it opens up directly in command prompt, but wat to do if i wish to do the same in ubuntu, i.e. i want the .py file to run in terminal as a console program, which does not happen as such.
View 14 Replies
View Related
Sep 2, 2010
I recently faced a problem. At my college, I linked my laptop with my friend's laptop with an ad-hoc wifi network. I wanted to send him a file. I was running Ubuntu, and he was running XP. Unfortunately, I could not find an easy way to send him the file. Another problem I faced was when I wanted to transfer the contents of my hard disk to another computer. I had to install Filezilla server on the other computer, and upload the files from one computer to the other.
I feel that its a really cumbersome method of transferring files in the same network. Mobile phones have bluetooth, and a file can be sent to another mobile very easily without any fuss. Does anyone know whether any such program exists already? If not, I want to write such a program that will allow one user to add another user to a personal network, and send or recieve files and/or communicate in other ways. The only language I know is Python (self-taught). I was wondering what GUI framework to use. I've never written a GUI program before, and would like to hear your opinions. This will be a very basic program, and must be able to run on many platforms.
View 6 Replies
View Related
Apr 7, 2010
i am trying to write a program which will read input from a text file, check if each line contains any alphabets and then display a message imforming me if there is an alphabet in each line. My text file is formatted in this way...
[Code]....
View 2 Replies
View Related
Feb 8, 2011
I opened a text file and read some stuff. Then I (think) I closed it. Then I tried to open another one and it stopped working. It seemed to compile fine though. Why would this be?
Code:
#include <iostream>// Libraries included
#include <string>
#include <fstream>
#include <sstream>
#include <list>
[Code]....
View 3 Replies
View Related
May 21, 2011
i am a new programer in c i have write a simple app and i have a problem with combiling my program include one header file and 2 c
fun.h
#include<stdio.h>
void f();
/******EOF*******/
fun.c
#include"fun.h"
void f(){
[Code].....
View 6 Replies
View Related
Jul 22, 2011
I am trying to write a bash script that installs a program fully automated for me. I am stuck at the one part where i need to change a line in one config file. I have tried various syntax for sed and none have worked. Maybe someone can suggest how to go about this. Since the line appears in the middle of the file, I can't use echo or cat. Also the file will be diffrent lengths depending on the install.
The line I need changed is:
I need that changed to:
the last syntax i tried is:
Yes this is for PNP4Nagios on centos 5.6 64bit. If i can get this figured out. I will be willing to post the whole thing for others to use. it will be used to install PNP after a working nagios install is done.
View 11 Replies
View Related
Sep 9, 2010
I am using ubuntu 10.04 and after installing some programs using the package manager I try to open the program and all I get is the title bar and a blank white screen. I searched the forums and found a thread from awhile back saying to create a new user and see if it persists. I tried that and it does the same thing in the new user. One in particular is gnucash. The program sometimes works but the tutorial does the white screen. I also reinstalled the package several times with no luck. Other packages do the same thing like thunderbird.
View 9 Replies
View Related
Jun 14, 2011
I want to launch the screen program by default and automatically every time that I open the bash terminal. How can I set this in terminal? I'm using lxterminal - terminal for lxde desktop environment.
View 2 Replies
View Related
Mar 23, 2010
I have this problem, however the solution given there is outdated- There is no such menu entry (I tried to see if it was disabled, but it wasn't in the menu editor either).
So how would I do this in Karmic?
Edit: I found it. As a reference: Open Nautilus, go to Edit-> Preferences -> "Media" tab -> Photos -> Your choice.
View 1 Replies
View Related
Dec 8, 2010
I am absolutely new to linux env. I have installed opensuse 11.2 with KDE desktop on my HP pavilion dv9700 Laptop. But I am having problem configuring my webcam. I have skype installed on my laptop and webcam is working OK with skype but when I run Opensuse program Digikam, it doesnt detect any camera.
View 2 Replies
View Related
Mar 21, 2011
I want to devolep one "C/C++" program that will work as a daemon. My daemon will be running all the time, and whenever anybody attaches removable devices to machine on which my daemon is running, My daemon should catch that event and also should show me where that device has been mounted.
View 1 Replies
View Related
Feb 15, 2011
I will have to code this. However I am lacking of time since I have too much to do. make a short code bash/dash to prompt the country with Zenity, then, get the PLS or m3u url and prompt with another zenity which radio to play. http://www.listenlive.eu/index.html
My code to get url's radio country.htm is:
Code:
View 2 Replies
View Related
Oct 19, 2010
i am investigating on solutions to trace a file deletion on a computer( Linux O/S).i also need to determine weither after a file deletion or download on a computer, the computer clock had not been modified. In case a file has been downloaded on a computer and then transferred to a removable device, i need to find out the file activity. i mean i should be able to tell that the file was downloaded and transferred to a device with possible specifications.
View 2 Replies
View Related
Apr 29, 2011
Is there a way to open a network interface (that is not configured, yet), to send and receive some packets? The program will be running with root permissions.
View 11 Replies
View Related