how to produce the nohup behaviour tabulation?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users how to produce the nohup behaviour tabulation?
# 1  
Old 11-17-2010
[SOLVED] how to re-produce the nohup tabulation behaviour ?

Hello everyone Smilie

By default, when you create a script and you type it in a terminal, when then you press TAB, it shows you the list of files in the current directory.

But with "nohup", instead, it shows you the commands list.

How could I reproduce the same behaviour with my script please? Smilie

Last edited by xib.be; 12-01-2010 at 01:17 PM.. Reason: solved
# 2  
Old 11-17-2010
Ah, I see what you mean.

In my shell, BASH, I was able to make it work by cheating: I made an alias like alias CMD="nohup cmd" ...and the shell was willing to tab-complete CMD. Which lets me run 'nohup cmd' without nohup stealing the first argument. Just tested it in ksh, it'll tab-complete there too.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 11-26-2010
héhé ^^ nice trick Corona688 but I would like to understand how "nohup" and "which" commands work ... so
BUMP Smilie
# 4  
Old 11-26-2010
Well, the shell always assumes the first argument is a program or builtin -- a safe guess, anything else would be invalid. The following arguments are assumed to be either local files or parameters totally unrelated to files -- usually a safe guess, since you wouldn't expect cat to open /bin/data when you tell it cat data.

But "nohup" looks in ${PATH} because it's designed to run global programs. It's special. It's a convenience program that lets you tack a 'nohup' onto the beginning of a command without otherwise modifying the statement. It works by closing all its own files, then replacing itself with the command you asked it to run, keeping the same set of open files. (This is how all shell redirection works, incidentally -- clone yourself, set up redirection as you want it in the clone, then the clone replaces itself with whatever you wanted run. This is also why you can't redirect a program that's already running.) The shell isn't aware of this behavior, and can't really be made aware of it.

There's a few other nohup-like commands like nice and strace and time, which all do various changes to a program's runtime environment before allowing it to run; nice reduces priority (i.e. makes it behave "nicer"), strace call-traces the program and prints all system calls to stderr, and time tracks the system/user/etc time a program consumes as it runs.

time is usually a builtin and not a real command, but even then she shell isn't smart enough to tab-complete time ca into time cat.

Last edited by Corona688; 11-26-2010 at 02:43 PM..
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 11-29-2010
thank you very much Corona688 for this complete explanation Smilie

finally I've found an academic way ^^
in fact there is a file /etc/bash_completion
which manages the completion in your bash shell.

In it , I search for "nohup", nice and so
I copy the correponding function and paste it in my .bashrc and of course replace nohup and so by my script name ...
Code:
complete -F _command -o filenames \
cmd1 \
cmd2 \
cmd3

et voilà !!

B-U-T !!! I have a new question now... does someone know a way to make regular expressions work in the .bashrc? for example it'd be cool to write
Code:
cmd[0-9]*

instead of
Code:
cmd1 \
cmd2 \
cmd3

but this doesn't work to
This User Gave Thanks to xib.be For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Do UNIX signals produce interrupts?

Hi folks! I have been reading Vahalia's Unix Internals book, which states the following in the chapter dedicated to signals: Given that, my understanding is that processes running in user mode don't become aware of signals until they switch to kernel mode, where the issig() function is called... (3 Replies)
Discussion started by: Tru69
3 Replies

2. Shell Programming and Scripting

Read 2 input and produce it in single ouput?

Hi all. I’ve 2 inputs here and would like to produce it in single ouput. I’ve drafted simple shell script but not sure how to put all this together. The final output should be “GROUP-XYZ” instead of “TEST” Please advise. INPUT1 GROUP-XYZ INPUT2 type8code0@box:~/dbedit$ cat... (8 Replies)
Discussion started by: type8code0
8 Replies

3. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

4. Red Hat

how to produce date command o/p

Hello I am trying of a solution to produce date cmnd o/p as: Feb 18 is the 049 day of the year. Any ideas how to produce this? (2 Replies)
Discussion started by: ranumala
2 Replies

5. Shell Programming and Scripting

get file content and produce command

hi buddies; ip.txt: 192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5 ... parameters.txt: portvalue username password session ... (2 Replies)
Discussion started by: gc_sw
2 Replies

6. Shell Programming and Scripting

awk to produce zip commands

Hi, I have a list of files which I want to rename and zipped up. The zip file will be split into small files when it contains 500 renamed file. Currently the way i am doing is like this. Get the filenames of the files in a list Generate another list containing the target filenames... (0 Replies)
Discussion started by: Leion
0 Replies

7. Shell Programming and Scripting

Perl Script to produce a file

hi i got a file called essay which contain few pages with many paragraphs. now i wanna with PERL to produce another file which called Essaylist that contain a sorted list of words that appear in the file essay. the format for Essaylist: $word found $times times on page a b c.... where $word... (3 Replies)
Discussion started by: mingming88
3 Replies

8. Shell Programming and Scripting

How to produce a file by many files?

i got these files: files: Prac1, Prac2, Prac3 (these 3 files have the same format), the format : Prac1 20693680 10 20179687 9 20781637 5 21907894 6 Prac2 20693680 8 20179687 6 21907894 2 Prac3 20693680 8 21907894 9 file STUDENTS, the format: 20693680:familyname, firstname (10 Replies)
Discussion started by: mingming88
10 Replies

9. Shell Programming and Scripting

Adding things in a file and produce a new one

I wanna add a ":" at the end of each line, and i did something like this: cat Totals | while read ID TOTAL do echo "${ID}:${TOTAL}:" >>Totals2 done File: Totals 12345678:13 21443433:20 The outputs file Totals2 is: 12345678:13:: 21443433:20:: but i want 12345678:13:... (3 Replies)
Discussion started by: mingming88
3 Replies

10. Shell Programming and Scripting

sed with tabulation

Hi! ;) I have a file: 122 10/11/04 123 10/11/04 124 10/11/04 126 10/11/04 127 10/11/04 130 10/11/04 131 10/11/04 132 10/11/04 133 10/11/04 Between the number and the date I have a tabulation. I want replace the tabulation with ; I have tried... (3 Replies)
Discussion started by: Castelior
3 Replies
Login or Register to Ask a Question