Make a bash script catch output from another app

Need help with C, C++, perl, python, etc?

Make a bash script catch output from another app

Postby Lavene » 2007-01-08 13:32

I'm working on a Python program that need to run as root so I use the following bash script to start it:
Code: Select all
#!/bin/sh

if [ `id -u` == '0' ]; then
   ./path/to/program.py
else
   kdesu ./path/to/program.py
fi


This works nicely except for one thing; The first thing the program does is checking for the availability of some Python qt modules. If they are not present the program prints out a nice warning and then exits. So I need the above script to catch this output and print it before exiting. And I don't know how to do that...

Thanks
Tina
Lavene
Site admin
 
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby Grifter » 2007-01-08 17:47

can you show me the output?
Eagles may soar, but weasels don't get sucked into jet engines...
Grifter
 
Posts: 1572
Joined: 2006-05-04 07:53
Location: Svea Rike

Postby Lavene » 2007-01-09 05:04

It just prints out a "Module not found" message to stdout. Working OK when I run the program directly but not when started via the bash script.

Code: Select all
try:
    from qt import *
except ImportError:
    print "Fatal error!"
    print "Module 'python-qt3' not found"
    sys.exit()


Tina
Lavene
Site admin
 
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby ajdlinux » 2007-01-09 08:13

-t Enable terminal output (no password keeping)


Attach -t to kdesu.
Jabber: xmpp:ajdlinux@jabber.org.au
Spammers, email this: ajdspambucket@exemail.com.au
ajdlinux
 
Posts: 2480
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

Postby Lavene » 2007-01-09 08:27

Douh!! *slap forhead* :oops:

Thanks!!

Tina
Lavene
Site admin
 
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable