Help using telnet to capture log file with autogenerate timestamp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help using telnet to capture log file with autogenerate timestamp
# 1  
Old 08-20-2013
Linux Help using telnet to capture log file with autogenerate timestamp

Hello,

I'm just joining, and looking for a solution to my problem.
I have an app act as server which forward log data using telnet (server). And in my centos machine, act as a telnet client to capture the data, and an application called recorder which readd those log data and to process it then erase it.

I have googled but haven't any luck.

I have try this command using terminal : telnet ip_address port | tee /home/user/$(date +%Y%m%d%H%M%S).txt

My application (recorder) read this text file then erase it.

The problem is, the $(date +%Y%m%d%H%M%S).txt files never created again after erased. The data capture must not stop in anyway, so telnet (client) keep capturing the log.

Is there any shell script to solve my problem?

Thank you before for your help.


=== Eddy ===
# 2  
Old 08-20-2013
You could try emptying the logfile instead of removing it in your application
Code:
> logfile

# 3  
Old 08-20-2013
Thank you for your reply.

But I'm a newbie for shell scripting. My Application (recorder) there's no option to emptying the file only.

The step is :

telnet --> create file *.txt
recorder --> get file *.txt --> erase after read

If there telnet capture new data, no *.txt file created.

Is there any solution?

Thank you.
# 4  
Old 08-20-2013
If that file gets erased but is still held open and being written to by tee, it continues to exist in the filesystem. You might be lucky to recapture it with a file system debugger; or, before deleting it, create a second link in a directory.
# 5  
Old 08-20-2013
Have a look at the logrotate command. If I'm correct, you could use it to recreate the logfile and run your application from it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Monitor and capture the latest entry from the log file

Hi, I want to monitor a log file using tail -f command and search for a specific string on the most recent entry from the file. If the search string matches with the most recent or last line from the file, I want send an email to the people with the message. tail -f service.log|tail -n 1 ... (5 Replies)
Discussion started by: svajhala
5 Replies

2. Shell Programming and Scripting

Script to capture string in a log file

Dear all, I have a log file to be analysed. this log file contains vaiours lines of code starting with date timestamp. if my search string is exception then that resepective log statement starting from the date is required. example: 2014/10/01 16:14:44.459|>=|E|X|19202496|2832|... (5 Replies)
Discussion started by: shravee
5 Replies

3. Shell Programming and Scripting

Capture all error message in Log file and send the Log file by email

Hi I have a requirement to write a script to capture all errors in a Logfile and send the file in email. If there is any error occurred the subject of email will be ERROR , If there are no error occurred the subject of email will be SUCCESS. So I created a Log file and put the Appropriate... (2 Replies)
Discussion started by: dgmm
2 Replies

4. Shell Programming and Scripting

How to capture output to log file

Hi I have a script that will run multiple unix & sql commands. I want to see the output as well as capture it to a log file for further analysis. Is there an easy way to do that instead of adding "tee -a logfile" on everyline or even on the execute line (i.e. script | tee -s logfile). Thanks (1 Reply)
Discussion started by: nimo
1 Replies

5. Shell Programming and Scripting

Delete log file entries based on the Date/Timestamp within log file

If a log file is in the following format 28-Jul-10 ::: Log message 28-Jul-10 ::: Log message 29-Jul-10 ::: Log message 30-Jul-10 ::: Log message 31-Jul-10 ::: Log message 31-Jul-10 ::: Log message 1-Aug-10 ::: Log message 1-Aug-10 ::: Log message 2-Aug-10 ::: Log message 2-Aug-10 :::... (3 Replies)
Discussion started by: vikram3.r
3 Replies

6. UNIX for Dummies Questions & Answers

DOS batch file to capture routers log

Hi, Please help to write DOS /Perl script to capture router AAA logs to store in file. RADIUS: id 1, priority 1, host 59.163.6.103, auth-port 1901, acct-port 1902 State: current UP, duration 1928071s, previous duration 0s Dead: total time 2798488914s, count 0 Authen:... (0 Replies)
Discussion started by: patilanna
0 Replies

7. Shell Programming and Scripting

capture in telnet

I'm trying to capture the files that this command types out, but i'm not able to do it. I'm pipeing everything to the telnet command because if i dont the connection closes. Any suggestions. #!/bin/ksh hostn='x.x.x.xx xxxx' (echo "open $hostn\r" sleep 3 echo " \r" sleep 2 (echo... (3 Replies)
Discussion started by: wisher115
3 Replies

8. Shell Programming and Scripting

Capture the command run in the log file

Hi , I have seen some log files where they have captured the command that is being executed, comments present in the scripts and the out put of the command as well, through scripts. could any one of you please let me know how do i do that? Thanks in advance. Cheers, Waseem (4 Replies)
Discussion started by: ahmedwaseem2000
4 Replies

9. Shell Programming and Scripting

capture nohup log file

Hi, I am running my script using nohup, but I am not able to capture the log file for that process could naybody please help... Here is what I am doing.... nohup ./script & 1>/home/user1/log.txt but I am not able to capture the log.....Is there anyother way I can capture the log... (2 Replies)
Discussion started by: mgirinath
2 Replies

10. UNIX for Dummies Questions & Answers

Spooling a log file with timestamp

Hi From shell script i am invoking sqlplus to connect to oracle database and then i spool a csv file as with output. What i want to do is to change the file name with timestamp on it so after spooling finish shell script change file name with time stamp. can someone help me to do that . Thanks... (2 Replies)
Discussion started by: ukadmin
2 Replies
Login or Register to Ask a Question