Ignore errors and all stdout drivel

Forum rules
Before you post please read how to get help

Ignore errors and all stdout drivel

Postby viking777 on Thu Dec 22, 2011 7:26 am

I am trying to string together several commands to run from one place (it is actually a .desktop file but it could equally well be a script if it has to be) and I want the commands to run irrespective of any output that is printed by stdout/stderr. At the moment the sequence is failing to run because of spurious complaints from the shell about non-existent errors (these are complete garbage I hasten to add - the program runs perfectly well despite whatever the command line is complaining about).

So far I have tried double ampersand, single ampersand, semicolon, comma, double pipe, and nothing at all, to separate the commands, but nothing works, the sequence always stops when one of the programs senses an error.

So what I want to achieve is similar to
Code: Select all
apt-get update && apt-get dist-upgrade


Except that I don't want the second command to be dependent on any conditions from the first command, I just want the next command to run irrespective of what has gone on before. Neither do I want any output redirected to anywhere else.

It should be simple but I can't find it.
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 14
Level 14
 
Posts: 5153
Joined: Mon Dec 01, 2008 11:21 am

Linux Mint is funded by ads and donations.
 

Re: Ignore errors and all stdout drivel

Postby Pilosopong Tasyo on Thu Dec 22, 2011 8:54 am

Use the ; operator and not the &&. Re-edit the launcher's properties and put the following in the Command field:

Code: Select all
gnome-terminal -e "bash -c 'apt-get update ; apt-get dist-upgrade'"

HTH.
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1206
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Ignore errors and all stdout drivel

Postby viking777 on Thu Dec 22, 2011 9:22 am

Thanks for that, but obviously I used a bad example as I don't want to launch a terminal.

This is what I have in the .desktop file at the moment:

Code: Select all
Exec=/bin/bash -c "checkgmail ; SpiderOak ; dropbox start ; sleep 3 ; killall gnome-shell"


But it isn't working and I think it is because of spurious output generated by either spideroak or dropbox or maybe both which prevents the sleep and killall commands from ever being run. There can't be much wrong with it because checkgmail is getting launched Ok. How would you write it?
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 14
Level 14
 
Posts: 5153
Joined: Mon Dec 01, 2008 11:21 am

Re: Ignore errors and all stdout drivel

Postby Pilosopong Tasyo on Thu Dec 22, 2011 9:45 am

Checkgmail is the culprit. If you run checkgmail from a terminal window, it will not return control to Bash unless you quit checkgmail from the panel. The other commands can't run because of the hold up. The workaround is to use checkgmail as a background process so that it returns control to Bash. Dropbox is ok. I can't comment on SpiderOak since I don't have/use it. You'll have to do a quick check like what I did with Checkgmail and Dropbox. If SpiderOak behaves like Dropbox (i.e. the Bash prompt is displayed after running SpiderOak), then the Exec line in the .desktop file should read:

Code: Select all
Exec=/bin/bash -c "checkgmail& SpiderOak; dropbox start; sleep 3; killall gnome-shell"

If, OTOH, SpiderOak holds the terminal up, use:

Code: Select all
Exec=/bin/bash -c "checkgmail& SpiderOak& dropbox start; sleep 3; killall gnome-shell"

HTH.
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1206
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Ignore errors and all stdout drivel

Postby viking777 on Thu Dec 22, 2011 12:29 pm

Pilosopong Tasyo, thank you very much for your reply. The second of the commands you gave was the most successful. Sadly it doesn't do what I want it to do but that wasn't what I asked here (maybe what I am trying to do can only be done manually), but as far as the question I asked in this thread goes, you have answered it very well, so thank you very much for your assistance.
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 14
Level 14
 
Posts: 5153
Joined: Mon Dec 01, 2008 11:21 am

Re: Ignore errors and all stdout drivel

Postby Pilosopong Tasyo on Thu Dec 22, 2011 10:06 pm

viking777 wrote:The second of the commands you gave was the most successful. Sadly it doesn't do what I want it to do...

I noticed you have the killall command at the end. I don't use gnome-shell, but every so often my Gnome 2.x panel misbehaves such that a particular launcher (Remote Desktop Viewer) doesn't show up. Killing gnome-panel usually fixes that. The unwanted side-effect, though, is my checkgmail icon disappears after the panel reloads, albeit it still runs in the background. So I have to kill checkgmail as well and reload it at the end.

Code: Select all
Exec=sh -c 'pkill checkgmail ; pkill gnome-panel ; exec checkgmail'

I do not know if the above situation is relevant to you. It's an educated guess, as I don't know the bigger picture to what you want to accomplish. But if you're trying to reload gnome-shell and the icons don't appear on the panel, then perhaps repositioning the killall command at the beginning instead of the end fixes it?

You're welcome, btw and HTH.
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1206
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Ignore errors and all stdout drivel

Postby viking777 on Fri Dec 23, 2011 5:15 am

What I was trying to achieve was in this thread here:

viewtopic.php?f=61&t=89494

But as mentioned in the last post on that thread I have kind of given up on it now because I can only make it happen manually, every way I have tried to automate the process has failed.

The behaviour you describe with checkgmail in gnome2 continues in gnome3 sadly. So before I gave up this little project I was part way to writing an exec line similar to yours for checkgmail, but as I can't get the automated restart of gnome-shell to work anyway, there isn't much point now.

Thanks again anyway. :D
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 14
Level 14
 
Posts: 5153
Joined: Mon Dec 01, 2008 11:21 am

Linux Mint is funded by ads and donations.
 

Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 1 guest