LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-03-2014, 03:29 AM   #1
Eagleshadow
LQ Newbie
 
Registered: Jul 2014
Location: Colorado
Distribution: Crunchbang
Posts: 9

Rep: Reputation: Disabled
Unhappy Problem Executing a Command in CB-exit


Cruncbang has a file called cb-exit (phython) I use sudo nano to edit this file. I was attempting to play a logoff wave file and I was told where to place the command:

I have done as told and yet the command simply will not execute: I used two versions of the command 1)
os.system("aplay /path to file) and 2)os.system("path to script.sh"). Neither works, I have run chmod 0755 and imported the path to files but no joy. Both commands run in terminal. Below is what I tried initially:

def logout_action(self,btn):
self.disable_buttons()
self.status.set_label("Exiting Openbox, please stand by...")
> os.system("aplay /home/william/Soundfiles/tada.wav")
os.system("openbox --exit")

I also tried > os.system("aplay -D plughw -q /home/william/Soundfiles/tada.wav")

I also tried the script
> os.system("bash /home/william/scripts/shutdown_tada.sh

Clearly there is something missing. Cb-exit is not broken and all is wellwith respect to shutting down.

Thanks
 
Old 07-05-2014, 02:51 AM   #2
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 384
Blog Entries: 2

Rep: Reputation: 96
Just a guess.. i don't have openbox installed here.

Maybe the sound doesn't get time to play, try combining the commands using "&&" like so:
Code:
os.system("aplay /home/william/Soundfiles/tada.wav && openbox --exit")
It should make the exit command run as soon as the sound has finished.
 
Old 07-06-2014, 11:02 PM   #3
Eagleshadow
LQ Newbie
 
Registered: Jul 2014
Location: Colorado
Distribution: Crunchbang
Posts: 9

Original Poster
Rep: Reputation: Disabled
Unhappy Cb-exit Shutdown Wav

Reasonable suggestion. I tried it and it didn't work. Nothing was broken and shutdown proceeded as if the aplay command wasn't there.

Thanks Anyway
 
Old 07-13-2014, 06:04 PM   #4
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
Quote:
Originally Posted by Eagleshadow View Post
> os.system("aplay /home/william/Soundfiles/tada.wav")
os.system("openbox --exit")

I also tried > os.system("aplay -D plughw -q /home/william/Soundfiles/tada.wav")

I also tried the script
> os.system("bash /home/william/scripts/shutdown_tada.sh
i'm not so sure about those ">" in there - they are not really in the script, yes? you just added them to highlight the crucial bits?

anyhow i tried this shutdown sound thing, and python is really picky about indentation, it's part of the syntax.
in my case, cb-exit wouldn't run anymore until i changed the settings in my editor and forced it to use tabs (many editors replace tabs with spaces).

but after that it would work just fine.
i think this syntax is even better:
Code:
<tab><tab>os.system("aplay /home/william/Soundfiles/tada.wav ; openbox --exit")
 
Old 07-14-2014, 01:56 AM   #5
Eagleshadow
LQ Newbie
 
Registered: Jul 2014
Location: Colorado
Distribution: Crunchbang
Posts: 9

Original Poster
Rep: Reputation: Disabled
ondoho

Interesting. I don't think the syntax is the issue as you imply. I am using sudo nano in terminal. The keys tabs are working and I saw nothing about tab options(I may know what I am looking for). I backed the cursor to the left of the page and hit <tab><tab> then edited the line os.system("aplay /home/william/Soundfiles/tada.wav ; openbox --exit"). That did not work so I must not be editing python correctly. Back to school!

Bill
 
Old 07-14-2014, 07:32 PM   #6
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
if you always edited it with nano, i don't see what could have gone wrong; i don't think nano replaces tabs with spaces.

but you could make sure to check it with another editor, maybe geany, that has an option to make tabs/spaces visible.

you could also just post the whole script as it is now.

anyhow, does it log out now?

and aplay does play the file when entered in a terminal?
 
Old 07-15-2014, 03:29 AM   #7
Eagleshadow
LQ Newbie
 
Registered: Jul 2014
Location: Colorado
Distribution: Crunchbang
Posts: 9

Original Poster
Rep: Reputation: Disabled
#!/usr/bin/env python


No problems playing aplay in terminal. I've done it dozens of times in different forms and even with a script. Logout works fine it seems as long as the indentation and syntax
is correct logout will work. Below the line is my pasted cb-exit.
-------------------------------------------------------------------------------------------

import pygtk
pygtk.require('2.0')
import gtks
import os
import getpass

class cb_exit:
def disable_buttons(self):
self.cancel.set_sensitive(False)
self.logout.set_sensitive(False)
self.suspend.set_sensitive(False)
self.reboot.set_sensitive(False)
self.shutdown.set_sensitive(False)

def cancel_action(self,btn):
self.disable_buttons()
gtk.main_quit()

def logout_action(self,btn):
self.disable_buttons()
self.status.set_label("Exiting Openbox, please standby...")
os.system("aplay /home/william/Soundfiles/tada.wav ; openbox --exit")

def suspend_action(self,btn):
self.disable_buttons()
self.status.set_label("Suspending, please standby...")
os.system("cb-lock")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.UPower\" /org/freedesktop/UPower org.free$
gtk.main_quit()

def reboot_action(self,btn):
self.disable_buttons()
self.status.set_label("Rebooting, please standby...")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/$

def shutdown_action(self,btn):
self.disable_buttons()
self.status.set_label("Shutting down, please standby...")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/$


^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text ^T To Spell
 
Old 07-15-2014, 04:51 AM   #8
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
what's the output of "whereis cb-exit" (and "whereis aplay")?
which file have you been editing (you are on crunchbang, right)?

(and in the future please use code tags for code)
 
Old 07-15-2014, 05:19 AM   #9
Eagleshadow
LQ Newbie
 
Registered: Jul 2014
Location: Colorado
Distribution: Crunchbang
Posts: 9

Original Poster
Rep: Reputation: Disabled
Guess I need to learn about code tags and whereis output. Yes it is crunchbang.

Sorry about my naivete.
 
Old 07-15-2014, 10:57 AM   #10
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
Quote:
Originally Posted by Eagleshadow View Post
Guess I need to learn about code tags and whereis output.
code tags: when you reply in normal/advanced mode (not quick reply), you can see a "#" in the editor's toolbar. click it, it will generate code tags (you can also just type those).
paste your code between those tags, it will be more readable.

whereis: open a terminal and literally type what i asked before. it will show you where the requested file is, if it's in your $PATH.

btw, you know you have to edit the file in /usr/bin with sudo?
but it's not recommended to change installed files; i don't know what will happen when you upgrade.
better to copy cb-exit to somewhere where you have user rights, edit it there without sudo, then point your openbox menu/hotkey to that file instead.
 
Old 07-17-2014, 03:44 AM   #11
Eagleshadow
LQ Newbie
 
Registered: Jul 2014
Location: Colorado
Distribution: Crunchbang
Posts: 9

Original Poster
Rep: Reputation: Disabled
As requested.

william@crunchbang:~$ whereis cb-exit
cb-exit: /usr/bin/cb-exit /usr/bin/cb-exit.save /usr/bin/X11/cb-exit /usr/bin/X11/cb-exit.save
william@crunchbang:~$ whereis aplay
aplay: /usr/bin/aplay /usr/bin/X11/aplay /usr/share/man/man1/aplay.1.gz

Code:
import pygtk
pygtk.require('2.0')
import gtks
import os
import getpass

class cb_exit:
def disable_buttons(self):
self.cancel.set_sensitive(False)
self.logout.set_sensitive(False)
self.suspend.set_sensitive(False)
self.reboot.set_sensitive(False)
self.shutdown.set_sensitive(False)

def cancel_action(self,btn):
self.disable_buttons()
gtk.main_quit()

def logout_action(self,btn):
self.disable_buttons()
self.status.set_label("Exiting Openbox, please standby...")
os.system("aplay /home/william/Soundfiles/tada.wav ; openbox --exit")

def suspend_action(self,btn):
self.disable_buttons()
self.status.set_label("Suspending, please standby...")
os.system("cb-lock")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.UPower\" /org/freedesktop/UPower org.free$
gtk.main_quit()

def reboot_action(self,btn):
self.disable_buttons()
self.status.set_label("Rebooting, please standby...")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/$

def shutdown_action(self,btn):
self.disable_buttons()
self.status.set_label("Shutting down, please standby...")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/$
 
Old 07-17-2014, 07:38 AM   #12
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
hmmmm... the whereis doesn't reveal anything except that you seem to be working on the proper file.

the script looks incomplete.
fwiw, it looks like this on my machine (slightly adapted, because it's archlinux, but basically the same, and as you see there's much more code).

assuming you simply omitted pasting the whole script, and also assuming the script works otherwise, and also assuming that the exact command:
Code:
aplay /home/william/Soundfiles/tada.wav ; openbox --exit
works as expected, there's nothing more i can do to help, as far as i can see...
 
Old 07-18-2014, 01:07 AM   #13
Eagleshadow
LQ Newbie
 
Registered: Jul 2014
Location: Colorado
Distribution: Crunchbang
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thanks anyway This a copy of cb-exit I got from a crunchbang forum. It seems different from your cb-exit although I am not clever enough to analyze it. I don't have a compare software package to detect differences.


#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass

class cb_exit:
def disable_buttons(self):
self.cancel.set_sensitive(False)
self.logout.set_sensitive(False)
self.suspend.set_sensitive(False)
self.reboot.set_sensitive(False)
self.shutdown.set_sensitive(False)

def cancel_action(self,btn):
self.disable_buttons()
gtk.main_quit()

def logout_action(self,btn):
self.disable_buttons()
self.status.set_label("Exiting Openbox, please standby...")
os.system("openbox --exit")

def suspend_action(self,btn):
self.disable_buttons()
self.status.set_label("Suspending, please standby...")
os.system("cb-lock")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.UPower\" /org/freedesktop/UPower org.free$
gtk.main_quit()

def reboot_action(self,btn):
self.disable_buttons()
self.status.set_label("Rebooting, please standby...")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/$

def shutdown_action(self,btn):
self.disable_buttons()
self.status.set_label("Shutting down, please standby...")
os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/$
 
Old 07-18-2014, 04:31 PM   #14
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
you are posting weird stuff.
if you don't use code tags i can't tell whether you accidentally formatted it wrong or whether the script is really borked.

you also haven't really reacted to any of my suggestions since the last few posts.

get yourself a copy of the cb-exit script as it is intended to be (it really isn't that hard to find a crunchbang repo mirror, meaning a place in the internet where all crunchbang software is stored - or maybe a git version) and start from scratch.
 
Old 07-19-2014, 01:57 AM   #15
Eagleshadow
LQ Newbie
 
Registered: Jul 2014
Location: Colorado
Distribution: Crunchbang
Posts: 9

Original Poster
Rep: Reputation: Disabled
Cb-exit Shutdown Wav

Sorry the last post was a mistake. I thought I had used code tags. You have been more than kind. I just did not have the time or skill to do everything I should have. I will go off and study as much as I can. You can close this thread if you like!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with executing a hell command from tcl Jykke Programming 1 04-25-2014 10:56 AM
Problem executing linux command remotely Vanyel Linux - Software 4 10-08-2010 07:51 PM
Problem with exit command shreyas_1 Linux - Newbie 6 04-29-2009 08:29 AM
Problem executing a command with pipes DeepSeaNautilus Programming 12 08-08-2008 02:28 PM
Problem executing from command line jleyba213 Linux - General 4 04-09-2004 01:43 PM


All times are GMT -5. The time now is 10:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration