You are not logged in.

#1 2011-07-26 03:08:34

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

[Solved] Launching Graphical Programs From The Terminal

Occasionally I launch graphical programs from the terminal and they usually spit out what they're doing in the background, I know you can send this output to /dev/null but is there a way to have that is the default setting (ex. not having to type &> /dev/null each time) and then somehow turn console output back on when I want to debug something? I tried creating an alias but that didn't work.

Last edited by brando56894 (2011-07-26 04:17:11)

Offline

#2 2011-07-26 03:16:57

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Launching Graphical Programs From The Terminal

Is

[karol@black test]$ jumanji &> log
[karol@black test]$ cat log

** (jumanji:4221): WARNING **: Error loading plugin: libhspell.so.0: cannot open shared object file: No such file or directory

good enough or do you want to detach it from the terminal (so you can issue another command)

[karol@black test]$ nohup jumanji &> log &
[1] 4249
[karol@black test]$ cat log
nohup: ignoring input

** (jumanji:4249): WARNING **: Error loading plugin: libhspell.so.0: cannot open shared object file: No such file or directory

[1]+  Done                    nohup jumanji &>log

Offline

#3 2011-07-26 03:45:59

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: [Solved] Launching Graphical Programs From The Terminal

I just want it so it doesn't dump anything out to the terminal, but without having to type a lot after each command to achieve this. Detaching it would be great because I usually have to open up another terminal when I do this.

Offline

#4 2011-07-26 03:47:16

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Launching Graphical Programs From The Terminal

Do you want to use the same file for logging or specify it every time? Overwrite the log or append new info?

Offline

#5 2011-07-26 03:54:19

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: [Solved] Launching Graphical Programs From The Terminal

I don't want to use any files. What I want to do is this: <programname> &>/dev/null with out having to type &>/dev/null each time

Last edited by brando56894 (2011-07-26 03:57:33)

Offline

#6 2011-07-26 03:55:46

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Launching Graphical Programs From The Terminal

But how will you debug - by launching it again, but w/o redirecting the output to /dev/null?

Offline

#7 2011-07-26 03:58:47

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: [Solved] Launching Graphical Programs From The Terminal

By that I meant just removing &>/dev/null or just not typing it if it's an alias or something like that.

Offline

#8 2011-07-26 03:58:57

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Launching Graphical Programs From The Terminal

brando56894 wrote:

I don't want to use any files. What I want to do is this: programname &>/dev/null with out having to type &>/dev/null

Write a function:

blah() { "$1"&>/dev/null ;}

Launch your programme with

 blah programme

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#9 2011-07-26 04:00:02

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Launching Graphical Programs From The Terminal

Place

foo () { nohup $@ &>> /path/to/log & }

with your other functions and aliases (like in .bashrc), adjust the function name and log's location.
The log will grow with use, so clear it once in a while.

Don't want a log - here you go

foo () { nohup $@ &>/dev/null & }

The usage is simple:

foo jumanji

I haven't done much testing so it may not always work.

Offline

#10 2011-07-26 04:03:50

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: [Solved] Launching Graphical Programs From The Terminal

Thanks, that's what I was looking for!

Offline

#11 2011-07-26 04:18:16

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: [Solved] Launching Graphical Programs From The Terminal

bashrun2 provides this via its remote feature. You can simply type the command and press Alt-Enter. Just install bashrun2, run it once and then add this to your .bashrc:

eval "$(bashrun2 --remote-control)"

Offline

#12 2011-07-26 04:19:30

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: [Solved] Launching Graphical Programs From The Terminal

I put it in my .bashrc and when I reload .bashrc I get this:

bash: /home/bran/.bashrc: line 12: syntax error near unexpected token `;'
bash: /home/bran/.bashrc: line 12: `no() { "$1"&>/dev/null & ;}'

Offline

#13 2011-07-26 04:22:48

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Launching Graphical Programs From The Terminal

What, exactly, did you put in your .bashrc?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#14 2011-07-26 04:22:57

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Launching Graphical Programs From The Terminal

brando56894 wrote:

I put it in my .bashrc and when I reload .bashrc I get this:

bash: /home/bran/.bashrc: line 12: syntax error near unexpected token `;'
bash: /home/bran/.bashrc: line 12: `no() { "$1"&>/dev/null & ;}'

Remove that '&' and try again. (remember to reload the .bashrc)

jasonwryan wrote:

What, exactly, did you put in your .bashrc?

He used your function but with "my" '&' - w/o 'nohup'.

Last edited by karol (2011-07-26 04:25:55)

Offline

#15 2011-07-26 04:31:18

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: [Solved] Launching Graphical Programs From The Terminal

how would I change my no function so that it detaches?

Offline

#16 2011-07-26 04:33:25

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Launching Graphical Programs From The Terminal

brando56894 wrote:

how would I change my no function so that it detaches?

Use the one I provided here https://bbs.archlinux.org/viewtopic.php … 05#p965605

foo () { nohup $@ &>/dev/null & }

Offline

#17 2011-07-26 04:36:06

brando56894
Member
From: NYC
Registered: 2008-08-03
Posts: 681

Re: [Solved] Launching Graphical Programs From The Terminal

Thanks, I wasn't sure if that did the same thing or not.

Offline

Board footer

Powered by FluxBB