•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,448 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,660 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1095 | Replies: 4 | Solved
![]() |
•
•
Join Date: Aug 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 1
hi
hope u guys are well... i am using a linux command (with system() call in my c++ code) to search all files with in the system and then store the results in the a file(say filename). i am piping this with tail --f filename to display the results while storing then in file 'filename'...
now as tail --f breaks when user breaks it( by ctrl +c) i was wondering is there anyother way to break this pipe
the command i am using is
find / -wholename= 'somename'>>filename | tail --f filename
my program doesn't continue until users breaks this command...
i was wondering whether there is a way to break this command when find is unable to find anynew file and append it to filename after some time interval....
my english is not very good if what i have written above is unclear please let me know....
i need to display the files found which are stored in filename at the same time on the terminal....
if i can not break from tail --f with out user break... is there anyother way e.g. let say that the file filename is checked after every 1 second to see if anything is written to it ...if anything is written to filename it is displayed ...if nothing gets written to file name say uptill 10 seconds the process breaks automatically...
i am sorry if this is the wrong question for this forum ..if that is the case can you please direct me to which forum i should put this question on thanks...i have searched on the net and books for a solution but i can not find any ..the closest thing i can think of it is to use the pid of find / -wholename='somename'>>filename to break the pipe but as i am a newbie i can not do that ..
thanks
hope u guys are well... i am using a linux command (with system() call in my c++ code) to search all files with in the system and then store the results in the a file(say filename). i am piping this with tail --f filename to display the results while storing then in file 'filename'...
now as tail --f breaks when user breaks it( by ctrl +c) i was wondering is there anyother way to break this pipe
the command i am using is
find / -wholename= 'somename'>>filename | tail --f filename
my program doesn't continue until users breaks this command...
i was wondering whether there is a way to break this command when find is unable to find anynew file and append it to filename after some time interval....
my english is not very good if what i have written above is unclear please let me know....
i need to display the files found which are stored in filename at the same time on the terminal....
if i can not break from tail --f with out user break... is there anyother way e.g. let say that the file filename is checked after every 1 second to see if anything is written to it ...if anything is written to filename it is displayed ...if nothing gets written to file name say uptill 10 seconds the process breaks automatically...
i am sorry if this is the wrong question for this forum ..if that is the case can you please direct me to which forum i should put this question on thanks...i have searched on the net and books for a solution but i can not find any ..the closest thing i can think of it is to use the pid of find / -wholename='somename'>>filename to break the pipe but as i am a newbie i can not do that ..
thanks
then do
Edit:
Although I am not familiar with "wholename" argument, I assume your find options are actually something different (and correct).
find / -wholename='somename' -print | tee -a filename
Edit:
Although I am not familiar with "wholename" argument, I assume your find options are actually something different (and correct).
Last edited by masijade : Nov 8th, 2007 at 10:01 am.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Aug 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 1
thanks for the reply... i checked
find / -wholename='somename' -print | tee -a filename
but i am getting an error which is "unexpected EOF encountered ". does the file filename has to contain something before i execute this command ??.... i thought this was happening because the file was empty and the only character the file had was the end of file character... but i entered sometext manually but i am still getting this error....
any suggestion??..
find / -wholename='somename' -print | tee -a filename
but i am getting an error which is "unexpected EOF encountered ". does the file filename has to contain something before i execute this command ??.... i thought this was happening because the file was empty and the only character the file had was the end of file character... but i entered sometext manually but i am still getting this error....
any suggestion??..
I would have to assume that it is coming from the tee (and that error will only occur on the file handle being read, not the filehandle being written), so I have to assume that the find command is not finding anything. But that also seems strange, as I believe that should have the same effect as doing
which as far as I know should not produce an error. Are you certain the error is happening here.
That error also occurs when a quoted string is not ended properly in the script so the shell continues reading the script as a part of the quoted string, but reaches the end of the file before reaching the end of the string as follows:
echo "" | tee -a filename
That error also occurs when a quoted string is not ended properly in the script so the shell continues reading the script as a part of the quoted string, but reaches the end of the file before reaching the end of the string as follows:
#!/bin/sh var="this is an unfinished string cat filename # never gets executed as the shell still considers this a part of the string above # here the script ends and produces the error given above as the string is not ended
Last edited by masijade : Nov 8th, 2007 at 6:56 pm.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- A simple text editor. How??!! (C++)
- help! (C++)
- vBulletin mod_rewrite (PHP)
- print out the solve word puzzle (C++)
- Compression/Decompression Wave File to MP3 and Vice Versa (C++)
- PHP in a html page? (PHP)
- how do you set a variable to be a filename? (C)
- wdm.dll backdoor.trojan (Viruses, Spyware and other Nasties)
- reading and printing a file to screen in C (C)
- About:Blank homepage ... (Viruses, Spyware and other Nasties)
Other Threads in the Shell Scripting Forum
- Previous Thread: Could use some help
- Next Thread: how to access variable outside awk and spliting the string in array



Linear Mode