Our environment: CentOS 5, which comes with Apache 2.2 and rsyslog 2.0.6
In order to send Apache 2.2 error log we followed instructions found on the here: http://wiki.rsyslog.com/index.php/Working_Apache_and_Rsyslog_configuration
It works, but the included perl script is very inefficient - it takes huge part of the system resources and from looking at the Sys::Syslog::syslog subroutine I can imagine why - it does lots of parameter parsing and moving around before it actually sends the message.
Is there some efficient C/C++ program to replace this script? It seems to be a 5-liner but I'd rather not re-invent the wheel.
Other solutions to efficiently send apache ERROR logs to syslog would also be welcome.
Thanks.
Actually it's pretty redundant - the "logger" command line utility will read standard input and send each line to syslog if it is not passed a message on the command line.
You are welcome anyway....:)
I'v written a C program which does the same function as the perl script in the link above.
It seems to take much less resources.
The program's source code was uploaded to the link in my question.
Related
I am using paramiko library to connect with a specialized environment. Its based on linux but when we SSH in it provide its own shell. We can write help to get list of all commands that are supported in that session.
I am using paramiko with python2.7 to provide a CLI client (it automates few things) that connect with the host and let us run the supported commands. Now I would like to provide tab-completion in the client CLI. I am not sure how this can be done. I am thinking there would be some support or some specialize character that can be send to get back response but I am not sure how it can be accomplished.
I am hoping to avoid sending help command, parse the list of commands supported, and then provide a local tab-completion based on list of command. I want a more generic and dynamic solution.
Any or all ideas are welcome.
You can try simulating the partial input and the Tab key press and parsing the results, undoing the simulated input afterwards. But that is not a good idea. You will have to end up re-implementing terminal emulation, what is an insane task. Without a full terminal implementation, you can never be sure that you never get an output that you won't be able to parse.
The shell is a black box with input and output. It should only be used as such. You should never try to "understand" its output.
Using the help command is a way more reliable solution.
Before asking this question I searched a lot about Logging (the terminal Debug Log) into a file for Tizen Application. I figured out some other ways to implement using several alternatives a bit complex pathway for this problem. But I want something straightforward, simple and builtin for Tizen Applications.
So here is what I want -
I will run a Tizen application written in C/C++. It will generate response logs on the terminal based on the several queries I ask to the app.
I want to save those logs into a specific file like file_name.log .
That file_name.log will be saved somewhere within my PC. Developer can change the location as my own.
Is there any command or an existing system for Tizen apps ?
Thank you in advance.
Read https://developer.tizen.org/development/guides/native-application/error-handling/system-logs about Tizen's built-in logging system.
As stated in the page, the logs can be also retrieved from the command line using sdb shell dlogutil [options...] [TAG], or simply sdb dlog [options...] [TAG]. So if you want to save the output as a file, simply do sdb dlog [-d] MY_APP > file_name.log. If this is not what you are searching for, please be more specific in your question.
I am using saxon xslt processor and python script to perform xslt transformations. I want to add exception handling to the python script. The saxon processor has inbuilt exceptions which are raised with codes (eg., SXXP003) etc. These error messages are displayed in the console because i am executing saxon files using batch file. The issue is that the saxon errors are not being written to traceback stack in python because of which i am unable to retrieve the error message. please provide a solution for the problem. I want to display the saxon error in the try except of python.
Regards
Anshul Mittal
Python has a number of different ways of invoking external programs via their command line interface: check whether the method you are using has any way of redirecting the System.err output stream. (I don't know Python so I can't advise on that aspect). If you can find a way to do this, then you can try to parse the error messages and extract the error codes.
A different approach, which might perform better and would give you more control (but which might involve more effort to configure correctly), would be to use the new Saxon/C product and invoke it via its C APIs, instead of invoking the Java product via its command-line interface.
In addition to Mike's reply, a python interface for Saxon/C is in development and worth a look:
https://github.com/ajelenak/pysaxon
I have an internal company need to create some sort of application which does the following daily at a specific time:
connects to our company's internal ftp url (not a secure url)
downloads a file with a specific file name
checks the newly downloaded file with the file downloaded the day before
throws an error if the file is the same or else displays a message saying all is good (or sends an email or something with that notification)
That's it. All i need to do is to check and make sure the file on the ftp is different from the day before.
Can anyone recommend an easy way of doing this? I've tried googling for a solution and not quite finding a straight answer.
I've been out of programming for the last 8 years but I still remember visual basic 6.0 and visual c++.
Please guide / suggest as you see fit.
Thank you :)
For vc++:
You could use any ftp client library for downloading a file. Take a look at this SO question which could be useful to you C++ FTP Library? . Then you need a proper way to chech the time. I think your program might need to run at statup and check for the system time at a specific interval if the time is due then download the file. For this you can take alook at this question How to get current time and date in C++? . Finally there are numerous ways for comparing the file and outputing the result, for starters is suggest you use the std.
I work on an application that usually runs unattended. Now I need to add to it something like an interactive prompt. In the interactive mode the operator will be able to give simple commands to the application - nothing fancy, simple commands like start and stop. Parametrized commands (e.g. repeat 10) and commands history could be nice too.
Do you know, by chance, any library that helps with such tasks. I've been thinking about something that works like boost::program_options or gflags but for an interactive prompt and not for command line parameters. Any ideas?
Thanks
Readline is one the best known libraries for this
http://tiswww.case.edu/php/chet/readline/rltop.html
It is covered by GPL, so it is only possible to use in GPL-compatible programs.
I did a quick search for alternatives, and found this:
http://github.com/antirez/linenoise
I'm not sure if the following is a reasonable amount of work for what you're trying to do, but Python has a very nice Command Line Interface (CLI) building library called cmd2. If it's possible to expose the relevant parts of your apps to Python using SWIG or CTypes, then doing the rest should be easy.
Here's a nice video presentation about cmd2:
PyCon 2010:Easy command-line applications with cmd and cmd2
HTH
One possibilty is to open a TCP port and accept messages in text format. Then you can telnet to that port and issue simple commands.