beep remote tmux when job is done - ssh

im a linux fan.
A few days ago i found tmux very useful.
Now im using it all day.
I run tmux on a remote shell and working there. On my local pc only one terminal working.
And i found interesting thing:
my mutt program is beeping when new mail arrives. And tmux is transferring this beep to my local PC, is there a way to run similar beep by any shell command ?
I want to use it for some command finishing sign.

I wrote a little script called beep.sh that I use for things like that:
#!/bin/bash
echo $'\a' > `/usr/bin/tty`

Related

Review all scripts that run after sshing into a machine

Is there a way to review everything that runs when I ssh into a machine?
Somehow when I ssh, it starts out with zsh, which is my default shell, but then later changes to fish shell. Want to find out where the fish shell is being called and delete that line.
Yan can add set -vx very early in your various zsh startup scripts ~/.zprofile, ~/.zshrc, etc. If the swicth to fish occurs even earlier, try the same with the zsh startup script in /etc.

Can I use windows utility installed on Windows system with WSL

I think the answer to my questions is NO. But I need to get clarity be certain about this.
EXAMPLE: I have sqlcmd windows utility installed on windows and can use it with command prompt, simply type sqlcmd in command prompt and start typing T-SQL commands such as sp_databases;go will list the databases.
Next if I want to use WSL bash prompt for doing the same I believe the only way to do so is to first install sqlcmd for Ubuntu from WSL bash and then log in to localhost SQL Server with sqlcmd.
Please share what you know to help me get a better understanding of how to get full benefit of WSL for doing things such as using the sqlcmd command at WSL bash prompt.
Thanks for the help.
I have tried issuing this command at the WSL bash prompt which did not work:
/mnt/c/Program\ Files/Microsoft\ SQL\ Server/110/Tools/Binn/SQLCMD.EXE
OK I had some success, I needed some getting use to but there is some thing to go off here. To reiterate my name idea was that if a program such as R or Python is installed in windows I shouldn't have to re-install it in WSL with sudo apt-get install ...
So for using the sqlcmd utility the following command at bash worked:
/mnt/c/Windows/System32/cmd.exe /C sqlcmd
This command will let give me a "black line/space" to type in T-SQL commands into. It gives me some success with my experiment, at first it looks funny since there was no prompt or anything but I just type the command sp_databases [enter] go [enter] and it does the trick.
Next I wanted to really wanted to test this and tried to run the R (installation that runs when I type >R at command prompt). This is command that worked at bash prompt:
/mnt/c/Windows/System32/cmd.exe /C R --no-save
This was more satisfying as it printed R intro and started the R-shell/prompt, the issue was though (what I immediately noticed) was that if I use the up arrow key to scroll through previous commands its won't work rather ^[[A is printed on the screen at the prompt.
Next I tried another program Python, at command prompt in windows if I enter >python it starts a python with the intro, but at WSL bash prompt when I tried:
/mnt/c/Windows/System32/cmd.exe /C python it takes me to blank line but unlike sqlcmd this time a simple python command like dir() dose not give back any output.
I would greatly appreciate if someone who knows more about these things could explain to me how I can use the programs already installed in windows with reinstalling them in WSL.
§ So why did the python program not start in WSL like it does at the command-prompt.
§ And in case of R program that did start how would I scroll through previous command if the up arrow key start printing ^[[A
Thanks for help, hope my question is clear enough.

tmux : config files are not used

I use tmux (tmux 1.8) from Ubuntu 14.04.
I wanted to configure it a bit via ~/.tmux.conf. But whatever I set inside this file my tmux session looks the same. Then I tried a fresh new /etc/tmux.conf but I still get the same display.
It seems that my config is hardcoded and that I cannot change it.
If I remove these two files (~/.tmux.conf and /etc/tmux.conf) my tmux session is still the same. Tmux runs but I can not configure it. But it should be so simple...
Does anybody have already seen this? And how I could solve that? Do I need to compile a fresh new release of tmux?
Today, I have more details :
on one machine it works as expected. It's OK. But I did not changed anything! Strange...
But on another machine (also running Ubuntu same release and up2date like the first machine) it does not work.
The file /etc/tmux.conf does not exist on none of these 2 machines. I put this little config file (~/.tmux.conf) :
# start Window Numbering at 2
set -g base-index 2
When I launch tmux on this second machine, window numbering starts at 0. On the first machine with the same config file, it behaves correctly : it starts at 2.
I'm going crazy!
After you make changes to ~/.tmux.conf make sure tmux sources them with the tmux source-file ~/.tmux.conf shell command.
Try removing all sessions before running tmux. I have noticed that if you have sessions still running, tmux will still load the previous .tmux.config file.
Executing tmux kill-server can stop the server and then try to run the server again using tmux command.
Please note that after killing the server you will lose all open sessions / tabs.

How to run a PHP script via SSH and keep it running after I quit

I'm trying to restart a custom IRC bot. I tried various commands :
load.php
daemon load.php
daemon load.php &&
But that makes the script execute inside the console (I see all the output) and when I quit the bot quits as well.
The bot author only taught me the IRC commands so I'm a bit lost.
You can install a package called screen. Then, run screen -dm php load.php and resume with screen -dR
This will allow you to run the script in the background, and still be able to use your current SSH terminal. You can also logout and the process will still be running.
Chances are good the shell is sending the HUP signal to all its running children when you log out to indicate that "the line has been hung up" (a plain old telephone system modem reference to a line being "hung up" when disconnected. You know, because you "hang" the handset on the hook...)
The HUP signal will ask all programs to die conveniently.
Try this:
nohup load.php &
The nohup asks for the next program executed to ignore the HUP signal. See signal(7) and the nohup(1) manpages for details. The & asks the shell to execute the program in the background.
Clay's answer of using screen(1) is pretty awesome, definitely look into screen(1) or tmux(1), but I don't think that they are necessary for this problem.
This line might help you
php load.php &

how to get a sound notification in terminal once a job has been completed

I run jobs on a remote machine . The jobs take a few mins to complete and I'd like a sound notification on my local machine in order to know that the job has been completed . Can anybody suggest a command if exists, or a tool that does this ?
Thanks
EDIT : I run jobs on remote machine, but need a sound notification (which has to obviously happen on local machine) upon completion ! Is that possible ?
Are you saying you run them one-by-one from the command line? I'm not in Linux atm, so I can't verify this, but I believe the bell escape character - "\a" - works in bash, so you should be able to do something like:
./dojob; echo "\a"
Again, this is off the top of my head, so test it with something like opening gedit followed by a bell or something.