Programming :: BASH: Detecting CTRL+C Being Pressed?
Jan 28, 2010
I am working on a script and I want it to detect if CTRL+C is pressed at any time during the script and have it not Break the script and display a message stating to use CTRL+Z instead. How can I do that?
View 9 Replies
ADVERTISEMENT
Jan 24, 2010
simple bash code:
Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do
[Code]...
How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!
View 10 Replies
View Related
Jan 10, 2011
I want to prevent "^C" from echoing when Ctrl-C is pressed. I did "stty -echoctl" which some googling results suggested. Now it echos raw Ctrl-C characters instead of the string "^C". That's not any better since it displays some funny blocked hexadecimal in the terminal window.
View 8 Replies
View Related
Jun 19, 2010
I want to be able to hide things so that they do not show up when show hidden files is pressed. Maybe something like a file that you can only get to by already knowing its location?
View 3 Replies
View Related
Jan 15, 2010
I am writing a bash script where I need standard Input should be saved in a file and should be terminated by passing CTRL+D signal. Any clue how can I do that in bash script.
e.g.
Enter one line at a time
Press CTRL+D to finish
View 1 Replies
View Related
Aug 19, 2009
i am using gcc 4.3i need to recognize ctrl+c,ctrl+l,ctrl+d in my C program without terminating the program when i get a ctrl+c...
View 1 Replies
View Related
Dec 5, 2010
I'm trying to write a init.d script to daemonise a sagemath notebook server. Here's what I've done so far, I've copied /etc/init.d/single for the structure, and tried to use dtach to provide a handle to access the process. However, my main problem is issuing the signals to kill the process (Ctrl-C) from a bash script and exit dtach (Ctrl-`)
[Code]...
View 1 Replies
View Related
Jul 4, 2011
I'm learning Signals, and I have a question:
Is possible to make a handle when I press any of the keyboard buttons?
The SIGINT handles the Ctrl-C combination, but I want to handle if any keyboard button was pressed.
View 3 Replies
View Related
Jul 5, 2010
I*am using Kubuntu 10.04. I would like to change some of the standard shortcut keys for bash (terminal).
I want:
Ctrl-C to copy the selected text to the clipboard.
Ctrl-V to paste from the clipboard into the terminal.
Ctrl-Z to undo.
Ctrl-Shift-C (or even better, Super-C) to terminate the command.
Ctrl-Shift-Z (or Super-Z) to be the background command.
I*don't even know what Ctrl-V did before, some I*won't worry about remapping it.
EDIT:*I*have no idea what is putting the * char after each "I". Maybe this is a non-breaking space?
View 14 Replies
View Related
Jan 18, 2010
I've tried without luck to get ctrl-backspace working to delete the previous word in bash. I edited my .inputrc and tried the following:
"C-": unix-word-rubout
Control-Rubout: unix-word-rubout
I can make it work if I change it to some other sequence (Control-j: unix-word-rubout makes ^j erase the word), but I can't make it work with backspace.
View 6 Replies
View Related
Jan 5, 2010
I have 3 layouts: USA, Russian and Hebrew. In Hebrew the W key is mapped to apostrophe, so Ctrl+W in Hebrew layout doesn't close tabs in Firefox. There is no workaround for it as I see by now, so I am trying to get it work this way:I want to map Ctrl+W in Hebrew layout(which is actually a Ctrl+') to be a Ctrl+w. Here is what I got from xmodmap:Code:$ xmodmap -pke | grep 25keycode 25 = w W Cyrillic_tse Cyrillic_TSE apostrophe WAs you can see, there are pairs for each layout, each pair tells what happens without and with the Shift key pressed.
View 2 Replies
View Related
Dec 27, 2010
I am doing a project on rdesktop. My aim is to setup a write/copy protected session. I have made rdesktop connection between two Linux machines using Xrdp.Next I want to disable the ctrl+x,ctrl+v keys and the cut and copy option in mouse right click at client side
View 1 Replies
View Related
Jul 25, 2010
I need to create a C/C++ program in Linux that succeeds in detecting how many tcp-sockets and what tcp-sockets are created by the other processes in the system in a particular time interval (e.g., the interval time this application is running in). Then, I'd need to get some information like local/remote port number and local/remote ip address of each of these sockets.
View 8 Replies
View Related
Dec 9, 2010
My C++ program must be able to detect EVERY Wireless Network Interfaces under Linux operating system and display the interface names on the screen.How can my application achieve this?Is there any sample codes?Is there any third party libraries can do this?Notes: The detected wireless network interfaces should also include the virtual interfaces, like the one created by Aircrack-NG's Airmon-NG script.
View 1 Replies
View Related
Jul 4, 2011
I am attempting to write a server application in C on a linux machine which listens for TCP connections and transfers data. I am trying to detecton the server side when the connection is broken. The closest thing that I got to work was looking at the return value from sending data. For example the server�s job is to mainly read data from the socket but to test if the connection is still up the server sends data periodically back to the client. I look at the return value from send() to determine if the connection is broken e.g.
Code:int ret = send(session->clientSocket, &data[sentCnt], count - sentCnt, MSG_NOSIGNAL)I found that this does not immediately return an error when the connection is broken. The reason for this is because even though the connection is broken send() is still successful because it is able to put it on the network buffer. To fix the issue I did the following things;
Code:
//set send timeout
struct timeval timeout;
[code]...
View 3 Replies
View Related
Apr 25, 2011
How to map special keys in vim, e.g. ctrl+< , ctrl+> , shift+< . I want to resize the windows in vim, ctrl+w+< is complex, I want map it to double press ctrl+< , how can I achieve it ?
View 2 Replies
View Related
Nov 28, 2010
" Mark the start of the text with "v", "V" or CTRL-V. The character under the cursor will be used as the start.""With CTRL-V (blockwise Visual mode) the highlighted text will be a rectanglebetween start position and the cursor."I can mark the start with "v" or "V".But it doesn't work when I push ctrl+V.
View 14 Replies
View Related
Sep 5, 2010
I can not copy/paste ctrl+C or ctrl+p from one folder to another with the mouse. i was trying to move an item to another folder.
I looked in the keyboard short cut and it was not there. i tried to add it and it put it in custom as disabled and I could not enable it.
View 2 Replies
View Related
Oct 3, 2010
anyone has a clue why 'ctrl+a, k' nor 'ctrl+a, :kill' doesn't work for killing one of screen windows? Other screen's commands invoked with 'ctrl+a'seem to work.
View 3 Replies
View Related
Jul 24, 2009
We have a system where users can upload files, and then various things happen depending on what kind file it is. The check uses the file command.But for Office 2007 files, the file command says it is a ZIP file.
These files are in fact ZIP files, I can unzip them, and then I get a lot of small weird files. We don't need to do anything about these files, but it's a problem when the system handles them as ZIP files.So I need some way of detecting these files, and not by file extension (.docx) since it is often incorrect. Many of the users are Macintosh users and they don't always use a file extension at all.
View 2 Replies
View Related
Nov 11, 2010
I just installed Ubuntu 10.10 x64 and already am really annoyed by Firefox, which freezes my mouse after changing a tab (with ctrl+tab, alt+#) or closing it (ctrl+w). After about one second, i can continue working as usual. Changing Tabs by just clicking on one does not freeze anything...Maybe some of you would think now if I am crazy because of complaining about such a little thing, but it is really annoying if you are used to work fluently with ff.Edit:I today noticed, that not only shortcuts in firefox, but all Hotkeys freeze my mouse for a second. For examle ctrl+c, ctrl+v, super+e or anything else.Do you have any Idea what causes this behaviour? Reinstalling ubuntu didn't change anything
View 4 Replies
View Related
Feb 4, 2011
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 3 Replies
View Related
Jun 2, 2010
changed terminal into raw modecfmakeraw(&termios);After that terminal no more captures CTRL+CIs there a way to enable CTRL+C (to terminate the program) while still have RAW mode?
View 3 Replies
View Related
Nov 26, 2008
I have a config file that contains:
my.config:
Code:
Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.
Here is my parse_cmd script:
Code:
View 3 Replies
View Related
Jul 25, 2011
I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.
Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?
View 5 Replies
View Related
Jan 6, 2010
How do I write my trap statement in shell script to ignore SIGINT.Reason being is that the script is used to update records in database. I want to avoid inconsistency in database when user presses Ctrl-C .The result should be
1. Totally ignore Ctrl-C (SIGINT) when user presses Ctrl-C
2. Continue with the rest of processing
View 3 Replies
View Related
Feb 3, 2010
I just spent a few days ripping out all the broken/buggy apps that are in the opensuse 11.2 official repos so I can finally get working software(openoffice, thunderbird, wine, eclipse, rubygems, rails, and a few others required getting the "official" versions from their respective websites to avoid strange behavior and outright broken functionality).
All of which makes updating more annoying and time-consuming. Why are opensuse packages so different anyway? Anyway, the last thing that I have noticed to fix is Konsole. For some really bizarre reason ctrl+z and ctrl+c do not work without a third keystroke: enter.Maybe this is something new with the KDE team, since they seem bent on making simple things that already work more complex, but given my experience with crappy packages in the suse repos, I am thinking this is the problem. I have looked over all the config settings that I can find and nothing fixes this affront to productivity.
View 1 Replies
View Related
Mar 7, 2010
I've been using Kaggregator in KDE-PIM, which uses Konqueror as the browserto go to links from Kaggregator.Unfortunately, Konqueror no longer seems tobe able to Copy highlighted material with Ctrl C, the way we've done it forever.Is this a setting I've missed? Or is this a new "feature" in Konqueror?
View 2 Replies
View Related
Apr 16, 2010
Using C++, I want to process sub-folders on my home folder sequentially each with a special naming format and containing some binary files in it:
Code:
1/
2/
3/
4/
5/
6/
...
Give above folders, I will process files in 1/ at first, 2/ at second, 3/ at third, and so on.
For some n/ folder, if I realize that n/ actually does not exist in local file system, I do not want to wait for it. Hence I will keep processing (n+1)/ folder, and so on.
However, when processing some (n+m)/ folder, previously not processed n/ folder may have been created on local file system. In this case, I do not want to miss processing it, but somehow detect its creation and process it. After processing n/ folder, I want to continue from (n+m+1)/.
View 5 Replies
View Related
Jan 9, 2010
I would like to get the filename (without extension) and the extension separately. The best solution I found so far is:
Let FILE="thefilenameofsomefilesfor_instance.txt"
Code:
NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`
I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.
View 5 Replies
View Related