How to get Xvfb display number - x11

How can I get the display number that used while running Xvfb?
For example somebody run
./Xvfb :14
I need somehow to get the used display number 14.
Thanks in advance

on a unix system, run
ps -ef|grep Xvfb
and it should list it there with the process

There are two ways I can think of:
Look for the lock files, which will typically take the form \tmp.X*-lock, where * is the display number;
Look at the log files, typically \var\adm\xfvb.log, but might be anywhere. There should be a line which says which display xfvb started listening to.

Related

win performance monitor: monitor service by using "command line" instead of "name"

I need to track a process by using performance monitor , and this is pretty simple
The problem is that I have more processes with the same name and basically i don't know which one i need
For example, take a look at the picture, i have two sql server but let's say i want to track the first one , how can i do that?
From what i see , the only difference is the command line so , would be great if i could track the one i need by using cmd line instead of name.
is it possible?
any idea?
img sample
Aside from the process name, there is also the process identification number (PID), which is unique for each process. It is listed in the task manager under the details tab.

Shell script - Multiple user appending the same file at the same time

I have a script in my server that displays its performance to the user in a text file. When the same script is executed in parallel by multiple users the information in the text file gets mixed up. I append many details of the server in the text file which takes roughly less than a minute to come up with the output. If i do file locking will it hit the performance or is there any way i need to look upon.
Please help me on how to proceed .
Thanks
Balakrishnan
You could make use of a message queueing system:
POSIX message queues:
http://www.linuxhowtos.org/manpages/7/mq_overview.htm
Beanstalkd: http://kr.github.io/beanstalkd/
POSIX Message Queue for Ruby: http://rubygems.org/gems/posix_mq
Perl: http://search.cpan.org/~iljatabac/POSIX-RT-MQ-0.03/MQ.pm
Python IPC: http://semanchuk.com/philip/posix_ipc/
Other threads:
Are message queues obsolete in linux?
https://unix.stackexchange.com/questions/70837/linux-command-to-check-posix-message-queue
https://stackoverflow.com/questions/40296/what-is-the-best-free-tool-for-managing-msmq-queues-and-messages
The idea is to create a server process that would receive messages and store on a buffer. It would only print a line on the logfile everytime a message from a process already has a complete line.
FLoM http://sourceforge.net/projects/flom/ can manage the lock you need: it's easy to use, it's fast, the same resource can be locked/unlocked by different users and it implements a rich lock model.
This example use case could give you some ideas about the tool: http://sourceforge.net/p/flom/wiki/Use%20Case%206/
Cheers
Ch.F.

Process Management w/ bash/terminal

Quick bash/terminal question -
I work a lot on the command line, but have never really had a good idea of how to manage running processes with it - I am aware of 'ps', but it always gives me an exceedingly long and esoteric list of junk, including like 30 google chrome workers, and I always end up going back to activity monitor to get a clean look at what's actually going on.
Can anyone offer a bit of advice on how to manage running processes from the command line? Is there a way to get a clean list of what you've got running? I often use 'killall' on process names that I know as a quick way to get rid of something that's freezing up - can I get those names to display via terminal rather than the strange long names and numbers that ps displays by default? And can I search for a specific process or quick regex of a process, like '*ome'?
If anyone has the answers to these three questions, that would be amazingly helpful to many people, I'm sure : )
Thanks!!
Yes grep is good.
I don't know what you want to achieve but do you know the top command ? Il gives you a dynamic view of what's going on.
On Linux you have plenty of commands that should help you getting what you want in a script and piping commands is a basic we are taught when studying IT.
You can also get a look to the man of jobs and I would advise you to read some articles about process management basics. :)
Good Luck.
ps -o command
will give you a list of just the process names (more exactly, the command that invoked the process). Use grep to search, like this:
ps -o command | grep ".*ome"
there may be scripts out there..
but for example if you're seeing a lot of chrome that you're not interested in, something as simple as the following would help:
ps aux | grep -v chrome
other variations could help showing each image only once... so you get one chrome, one vim etc.. (google show unique rows with perl or python or sed for example)
you could use ps to specifiy one username... so you filter out system processes, or if more than one user is logged to the machine etc.
Ps is quite versatile with the command line arguments.. a little digging help finding a lot of nice tweaks and flags in combinations with other tools such as perl and sed etc..

how do I enter the input to ruby program when it is running some other tool

I have a requirement where I need to run the ruby script in WINDOWS and which will have the following command
test.rb
Dir.chdir("C://mtn-2//mtn-2.2//bin//")
system("CadTestNode.bat")
Here am running some tool called mtn tool, once I run this program it will display the following in the output pane
CAD Message Test Node
Select from the following options:
m - Show Menu
c - Create Test Case Connection
a - Execute All Test Cases
t - Terminate All Test Cases
x - Terminate Test Case Connection
s - Set Sequence Number
q - Quit
Enter choice:
After this the script is stucked in between, its asking for the input. My question is, is there any way to provide the input via script itself? Onemore thing, here I need to provide input 2-3 times. Is it possible to automate this kind of scenario as am running some other tool from the ruby script.
Thanks inadvance, waiting for your early reply.
Use pipe (Open3) instead of system and you will be able to read from external program as well as reply to it. Of course, for Windows you will have to install win32-open3 from http://rubyforge.org/projects/win32utils
You can use gets() to get the input, as for the rest (automate) sure, why not. Instead of my_input=gets.chomp do my_input='my predefined actions' and parse it accordingly.

Count number of executions of batch-script

This is my problem, I've got a batch-script that I can't modify (lets call it foo) and I would like to count how many times/day this script is executed - to keep track of that data.
Preferably, I would like to write the number of executions with date and exit-code to some kind of log file.
So my question is if this is possible and in that case - how? To create a batch-script/something that works in the background and writes every execution of foo to a log.
(I know this would be easy if I could modify foo but I can't. Also, everything is running on WinXP machines.)
You could write a wrapper script that does the logging and calls the existing script. Then use the wrapper in place of the original script
Consider writing a program that interrogates the Task Manager.
See http://www.netomatix.com/ProcDiagnostics.aspx
You could, for example, write a simple Console app which runs on a timer; every 5 seconds it checks that your foo application process exists. If it finds that it does, it assumes that find as the start time of the application; if it doesn't find it, it assumes the application has now closed and logs that information. It wouldn't be accurate to the second by any means, but would give you a rough approximation of when the thing is running and closing.
You might be able to configure Process Monitor
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx to capture the information you require

Resources