Page 1 of 1

Ignore errors and all stdout drivel

Posted: Thu Dec 22, 2011 7:26 am
by viking777
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.

Re: Ignore errors and all stdout drivel

Posted: Thu Dec 22, 2011 8:54 am
by Pilosopong Tasyo
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.

Re: Ignore errors and all stdout drivel

Posted: Thu Dec 22, 2011 9:22 am
by viking777
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?

Re: Ignore errors and all stdout drivel

Posted: Thu Dec 22, 2011 9:45 am
by Pilosopong Tasyo
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.

Re: Ignore errors and all stdout drivel

Posted: Thu Dec 22, 2011 12:29 pm
by viking777
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.

Re: Ignore errors and all stdout drivel

Posted: Thu Dec 22, 2011 10:06 pm
by Pilosopong Tasyo
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.

Re: Ignore errors and all stdout drivel

Posted: Fri Dec 23, 2011 5:15 am
by viking777
What I was trying to achieve was in this thread here:

http://forums.linuxmint.com/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