xdotool is not functioning properly when I start my vnc session using Xvnc instead of vncserver - vnc-server

I was using xdotool in my GUI tests and it was functioning properly. Then I had to change my tests to start the vnc session using Xvnc command instead of vncserver command (TigerVNC 1.8.0) because the vncserver command was failing on some machines, that's when my tests starts to fail. When I run the tests I find that commands like
xdotool key Return
never get executed (the command doesn't error however no return key is pressed). Anyone knows what could have caused that and how to fix it?

Noticing the processes that vncserver command runs vs the processes Xvnc command runs, I noticed that vncserver runs a Xvnc server process and also runs that script
~/.vnc/xstartup which starts the window manager that xdotool seems to need to function properly. My xstartup file contents:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
vncserver -kill $DISPLAY

Related

How to tell Bash to not stop the simulations when ssh disconnects?

I am running some simulations on another machine via ssh. Here is what I do
ssh username#ipp.ip.ip.ip
Go to the right directory
cd path/to/folder
And then I just call my executable
.\myexecutable.exe
The issue is that every time the ssh disconnect, the simulations stops. How can I make sure the simulations doesn't stop on the other machine? Will I somehow receive potential error messages (assuming the code will crash) once I reconnect (ssh)?
You should launch a screen or tmux to create a terminal from which you can detach, leave running in the background and later reattach.
Further reading:
http://ss64.com/osx/screen.html
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/screen.1.html
You may also want to try out Byobu:
http://byobu.co
run your command as follows : nohup ./myexecutable.exe >nohup.out 2>&1 &
The & is to run the command in the background
The >nohup.out 2>&1 sends your stdout and stderr to nohup.out)
Note the '/' as opposed to '\' - which won't work on osx

Unix - Suppress informatory messages

I am trying to execute a remote command for one of my scripts. I have to run this script across many servers. so i will put it in a script. What I am trying to do is
ssh root#10.158.42.12 nohup perl /script/myscript.pl 06/04/2014 60 &
The script runs just fine but there is an info message which is displayed whenever you try to login . The one many of you would be familiar with ..
|-----------------------------------------------------------------|
| This system is for the use of authorized users only. |
| Individuals using this computer system without authority, or in |
Due to this the script execution is haulted unless an enter is pressed. I want to put the script in a cronjob for automatic execution, so i dont need to see this info message.
Here's my theory:
Your command doesn't run the program in the background on the server. It runs runs the program in the foreground on the server, and then you background ssh.
Since ssh runs in the background, you are immediately returned to your prompt.
Milliseconds later, ssh overwrites your prompt with this message and runs the command.
You are now looking at the ssh message and no prompt.
You hit press enter, which causes the prompt to be redrawn on the next line.
This leads you to believe ssh was actually waiting for you to press enter. In reality, the command was already run, and bash was ready for new commands, just obscured by ssh noise.
How to test:
If I'm right, pressing Ctrl+L instead of Enter will clear the screen and show the bash prompt. (assuming you don't use bash's vi mode).
If I'm not, Ctrl+L will instead either do nothing, print the ssh message again or just write ^L to the screen.
How to fix if I'm right:
ssh -f root#10.158.42.12 'nohup perl /script/myscript.pl 06/04/2014 60 &' 2> /dev/null

tmux session closes when ssh terminal closes

What I am trying to do:
I am trying to execute couple of bash commands on a remote machine using ssh and I want those commands to finish execution even after ssh-session is closed in the middle of execution.
What I have done so far :
I am using Putty to connect to ssh (one of the reasons of using putty is that one machine is windows and remote machine is mac-os and I need some way to initiate ssh through Python command). I am passing command.txt file and it contains all the commands I want to execute.
putty -ssh start-ts#ip.000.001.101 -m command.txt ( not real ip)
command.txt : looks like this :
export PATH=$PATH:/usr/local/bin
echo $PATH; sleep 1
tmux -c 'queue.sh'
sleep 100
After connecting to ssh, to make sure that my script/commands continue running on remote machine even after ssh-session is closed on another machine, I am using 'tmux'
But the Problem is :
Even after using tmux, processes called by queue.sh terminate as soon as I close ssh-session.
I have also tried
export PATH=$PATH:/usr/local/bin
echo $PATH; sleep 1
tmux
queue.sh
sleep 100
does the same thing.
What I also tried :
If I just pass following commands using ssh (in command.txt)
export PATH=$PATH:/usr/local/bin
echo $PATH; sleep 1
tmux
and then manually type queue.sh in tmux terminal, is that case I can close ssh-terminal and remote machine continues execution of processes.
Any suggestion ?
I want to be able to pass everything though script files and keeping the processes running on remote machine (mac-os) even after closing ssh-session on another machine.
Thanks
The -c option doesn't actually start a new session; it's for compatibility with other shells if you use tmux as a login shell. In order to run queue.sh in a tmux session, try starting tmux with
tmux new-session queue.sh

decouple process remotely launched from local machine

I need to ssh to a machine and launch a bash script running some hour-long tests which require no human interaction for their entire execution.
Is there any way I can decouple my running script from my shell, so that I can close the terminal and shut down my local computer as I like?
Sure, use nohup:
nohup ./program &
Alternatively, start your program inside screen or tmux and then detach.

Terminal Command: start or stop process if it's running or not

I have a glassfish install and I would like to have a simple terminal command checking if it's running. If it is, it will shutdown the process. Or if it not running, it will start the server.
To start the server I can enter:
/Applications/NetBeans/glassfish-3.1.1/bin/./asadmin start-domain domain
To stop the server I can enter:
/Applications/NetBeans/glassfish-3.1.1/bin/.asadmin stop-domain domain
I will would like to make a simple Alfred.app script than can start this domain if it's not running, or stop it if it's running.
One way to do this is to note in a file the process ID of the server when it starts, and have another script check to see if that process is running.
For example, script A (to run the server unconditionally):
#!/bin/sh
/Applications/NetBeans/glassfish-3.1.1/bin/./asadmin start-domain domain
# file name is arbitrary
pgrep whateverTheProcessNameIs > ~/.glassfish-server.pid
And in script B:
#!/bin/sh
pid=`pgrep -F ~/.glassfish-server.pid` # file chosen in script A
if [ "x$pid" = "x" ] ; then
# process has died; restart by running script A
/path/to/scriptA
fi
Note that only Mac OS X 10.8 (Mountain Lion) installs pgrep by default; otherwise you'd have to use some other method (like parsing ps output) to see what processes are running.
As far as how to run this check periodically, there are various ways. I'm assuming Alfred will run any script that is executable (chmod +x scriptA scriptB) but I don't know for sure.

Resources