I know things similar to this have been asked many times.
I've recently made the switch from Gnome to Awesome. My current terminal is urxvt. Using the copy buffer is fine, I know I can insert into the terminal from this using [CTRL]+[Ins] (or middle mouse click) and do so very frequently.
The issue lies when something is in the clipboard. I use pass as my password manager and when I issue the command pass -c this copies the password to the clipboard then wipes it after a short period of time, which I do not have a problem with.
The issue is when I am prompted for one of these passwords in the terminal. If it was in the copy buffer I could just [CTRL]+[Ins] when prompted. So the main question really becomes how do I set a keyboard combination to paste from the clipboard for urxvt/xterm?
Ideal scenario (using mysql as example):
$ pass -c mysql-root
Copied mysql-root to clipboard. Will clear in 45 seconds
$ mysql -uroot -p
Enter password: <keyboard combination>
root#localhost>
There are perl rxvt extensions to work with the clipboard. Add this to your .Xresources file and "xrdb -merge .Xresources" before starting awesomewm
URxvt.perl-ext-common: default,clipboard
On my awesome-wm setup on FreeBSD the default is shift-ins to insert both primary and clipboard buffers. But this might be different on your os/distro.
Arch linux wiki has a detailed guide on how to set up rxvt, https://wiki.archlinux.org/index.php/rxvt-unicode#Cut_and_paste. The instructions can be applied on any linux distro with minor tweaks.
Turns out the correct combination for the clipboard in my environment is [CTRL] + [ALT] + V.
The buffer is still [CTRL] + [Ins].
Related
As Part of data Analysis, I need to connect excel macros with unix, fire my shell script from a macro, and get the output file back to excel. I tried using winsock, but it didn't work
This is not a very clear question...
but i suggest to split the problem into parts
test the shell script to make sure it outputs exactly what you want (including carriage returns / whitespace / other fromatting that might confuse Windows or Excel)
test your method of connecting from Windows to Unix. make sure you can run a command from PowerShell which logs in to the unix machine, runs the script, and returns the result
test your Excel macro. ensure it has permission to make the connection you made from PowerShell
You'll have better luck on StackOverflow if you post a piece of code (or network details) and the error message you got from that code.
I enjoy running Postgres client "psql" under psql.el while interacting with a .sql file in a separate window. Sometimes, I want to use tab-completion within the the buffer running the psql process to find the name of an appropriate table name. However, I can not figure out how to cause the desired result.
A very related question has been asked here: https://superuser.com/questions/236574/how-can-i-send-a-literal-tab-to-bash-in-emacs-shell-mode
without any successful suggestions.
Thanks in advance!
SetJmp
Usually programs that designed for interactive use (when they own terminal) disable interactive features (like history for UP/DOWN, completion for TAB) when used in pipe.
Emacs usually use pipes for external processes. So interactive features are disabled.
Even if you send TAB, your client program does not interpret it for you as you want.
You can read man/help for your program and try force interactive mode by providing command line switch (like --login for GNU Bash).
To send TAB eval:
(defun my-comint-send-string (string)
"Send string to comint buffers. Useful for *compilation* read-only buffer."
(interactive
(list (read-input "Type string: " nil 'my-comint-send-hist-list)))
(comint-send-string (get-buffer-process (current-buffer)) string))
(define-key XXX-mode-map [C-return] 'my-comint-send-string)
and use such key sequence: C-RET C-q TAB RET.
But this may not work if buffering is enabled for stdio of your program (to flush input you must send \n too)...
Mostly same problem discussed at Bash autocompletion in Emacs shell-mode
NOTE M-x term use pseudo terminal so all interactive program work as desired. But in this mode you lose any Emacs editing capabilities...
I've previously used sql-oracle just fine in Xemacs on XP and vista.
However, now I'm using Postgresql psql on the command line but I kinda find it lame (as compared to using sql-* from within emacs)
So, I'm trying to get it(psql) working within xemacs(21.4.22) on windows. When I type
M-x sql-postgres ENTER, I get the following 3 prompts
User:
Database :
Server:
How come I am not prompted for password ? It presents a SQLi buffer but when I type my SQL in and press ENTER nothing happens. Also, I don't see any prompt (when I run psql from cmd.exe, I get the "databasename=#" prompt).
What gives ?
What am I expected to enter in the above prompts for a DB which is running on my box(localhost) and I know which DB that I need to connect to(I know what params to give psql but not in xemacs).
I tried the same with GNU Emacs (23.1.50.1 (i386-mingw-nt6.0.6001)) and the results
were similar :
A SQLi buffer but none of the SQL get executed and I didn't see a prompt for password.
Thank you,
BR,
~A
On Windows, psql, like ftp, is known to not work correctly under shell-mode as it's not using the stdin, stdout handles, but a console handle.
See Emacs FAQ for Windows / 7.2 Programs reading input hang
Is there a way to force a Samba process to close a given file without killing it?
Samba opens a process for each client connection, and sometimes I see it holds open files far longer than needed. Usually i just kill the process, and the (windows) client will reopen it the next time it access the share; but sometimes it's actively reading other file for a long time, and i'd like to just 'kill' one file, and not the whole connection.
edit: I've tried the 'net rpc file close ', but doesn't seem to work. Anybody knows why?
edit: this is the best mention i've found of something similar. It seems to be a problem on the win32 client, something that microsoft servers have a workaround for; but Samba doesn't. I wish the net rpc file close <fileid> command worked, I'll keep trying to find out why. I'm accepting LuckyLindy's answer, even if it didn't solve the problem, because it's the only useful procedure in this case.
This happens all the time on our systems, particularly when connecting to Samba from a Win98 machine. We follow these steps to solve it (which are probably similar to yours):
See which computer is using the file (i.e. lsof|grep -i <file_name>)
Try to open that file from the offending computer, or see if a process is hiding in task manager that we can close
If no luck, have the user exit any important network programs
Kill the user's Samba process from linux (i.e. kill -9 <pid>)
I wish there was a better way!
I am creating a new answer, since my first answer really just contained more questions, and really was not a whole lot of help.
After doing a bit of searching, I have not been able to find any current open bugs for the latest version of Samba, please check out the Samba Bug Report website, and create a new bug. This is the simplest way to get someone to suggest ideas as to how to possibly fix it, and have developers look at the issue. LuckyLindy left a comment in my previous answer saying that this is the way it has been for 5 years now, well the project is Open Source the best way to fix something that is wrong by reporting it, and or providing patches.
I have also found one mailing list entry: Samba Open files, they suggest adding posix locking=no to the configuration file, as long as you don't also have the files handed out over NFS not locking the file should be okay, that is if the file is being held is locked.
If you wanted too, you could write a program that uses ptrace and attaches to the program, and it goes through and unlocks and closes all the files. However, be aware that this might possibly leave Samba in an unknown state, which can be more dangerous.
The work around that I have already mentioned is to periodically restart samba as a work around. I know it is not a solution but it might work temporarily.
This is probably answered here: How to close a file descriptor from another process in unix systems
At a guess, 'net rpc file close' probably doesn't work because the interprocess communication telling Samba to close the file winds up not being looked at until the file you want to close is done being read.
If there isn't an explicit option in samba, that would be impossible to externally close an open file descriptor with standard unix interfaces.
Generally speaking, you can't meddle with a process file descriptors from the outside. Yet as root you can of course do that as you seen in that phrack article from 1997: http://www.phrack.org/issues.html?issue=51&id=5#article - I wouldn't recommend doing that on a production system though...
The better question in this case would be why? Why do you want to close a file early? What purpose does it ultimately have to close the file? What are you attempting to accomplish?
Samba provides commands for viewing open files and closing them.
To list all open files:
net rpc file -U ADadmin%password
Replace ADadmin and password with the credentials of a Windows AD domain admin. This gives you a file id, username of who's got it open, lock status, and the filename. You'll frequently want to filter the results by piping them through grep.
Once you've found a file you want to close, copy its file id number and use this command:
net rpc file close fileid -U ADadmin%password
I needed to accomplish something like this, so that I could easily unmount devices I happened to be sharing. I wrote this quick bash script:
#!/bin/bash
PIDS_TO_CLOSE=$(smbstatus -L | tail -n-3 | grep "$1" | cut -d' ' -f1 - | sort -u | sed '/^$/$
for PID in $PIDS_TO_CLOSE; do
kill $PID
done
It takes a single argument, the paths to close:
smbclose /media/drive
Any path that matches that argument (by grep) is closed, so you should be pretty specific with it. (Only files open through samba are affected.) Obviously, you need root to close files opened by other users, but it works fine for files you have open. Note that as with any other force closing of a file, data corruption can occur. As long as the files are inactive, it should be fine though.
It's pretty ugly, but for my use-case (closing whole mount points) it works well enough.
The question is special because some keys, such as CTRL+Z, stopped working.
I tried to put the process to background by typing in the order:
find /
CTRL+Z
bg
However, I can still see the stdout. The only difference to only doing the first step is that the command CTRL+Z does not work anymore. It is rather nasty when I have unsaved jobs and my harddrive is over 100GB. So
how can I put the process to background?
[Details]
I am using the fourth version of Bash on Mac.
[Crux Reply by Nicholas Riley]
The problem is really that I do not understand the "ramifications" of running process background. I cannot understand why the commnands, such as CTRL+Z, do not work to background processes. I was still able to kill the process in another shell with the command:
ps -ej | awk '! /grep/ && /find/ {print $2}' | xargs kill -9
^Z isn't working because the frontmost job is now the shell, and shells don't usually respond to SIGTSTP. (If you do really want to suspend a non-login shell, suspend usually works.)
The problem seems to be you misunderstand the ramifications of a job being in the background. Redirecting the job's standard output is unrelated.
In fact, it's unclear what you want to do. If you just want to stop find from running, then fg it and use ^C or ^\ (which by default send SIGINT and SIGQUIT respectively).
If you want to keep find running but suppress its further output, then the easiest solution I can think of is to use bg ; disown ; exit. That will stop the shell from killing its child process (find) and exit the shell; assuming it's at the top level of the Terminal window, you'll see a bit more output and find will keep running (but you'll have no way to interact with it).
I use disown.
find / & disown
exit # close the terminal and the command still runs
You can use disown after you ^Z as well:
find /
^Z
bg
disown
exit
disown is a bash builtin, I believe. Not sure about alternatives for other shells.
For further information, see my equivalent answer on Server Fault.
You can set the operation to a different key with stty on any UNIX-like system.
$ stty susp Q
will make Q your suspend key in place of CTRL-Z.
Backgrounding a process will not disconnect the output from the terminal device, that's why you're still seeing output and the output may well contain control characters which can stuff up your TTY settings (cating binary files is a good way to do that).
If you want the job to run in the background, do it right:
find / >/tmp/out 2>&1 &
then examine the /tmp/out file when it's finished.
I usually do this kind of thing with nohup. Like this:
nohup find / > /tmp/myresults.txt &
nohup makes sure that the process doesn't stop, even if the console goes away (like, you close the window or lose your SSH or whatever). The ">" sends output to a file rather than to the console, and "&" puts the job in the background.
I'll assume you're using a common variant of Linux or UNIX and possibly the bash shell. In which case:
CTRL-Z sends the SIGTSTP signal to the foreground process. You should be able to do the same thing with the kill command by specifying kill -s SIGTSTP [pid].
I know that in Ubuntu 9.04, you can start the process with a & after it to run it in the background. For example, "sudo gedit /boot/grub/menu.lst &" will start a text editor editing the GRUB config file in the background.
kill -STOP your_pid_here
from another console window?
http://tombuntu.com/index.php/2007/11/23/how-to-pause-a-linux-process/#comment-132413