Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 14th, 2006, 6:05 PM   #11
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Quote:
How would you perform this in Linux?
If you're asking about opening a webpage or viewing an image on the web then read my previous post.
os.system("program-name")
launches the program specified by 'program-name', e.g os.system("firefox") would start firefox if it's installed.
If you just want to open an application you don't want os.startfile on Windows at all, as that loads the given file in the application that is associated with it (by default notepad for a .txt file, Windows image viewer for .jpg, etc). Probably not what you wanted.
Cerulean is offline   Reply With Quote
Old Jun 14th, 2006, 11:38 PM   #12
Silicon_Pudding
Newbie
 
Silicon_Pudding's Avatar
 
Join Date: Jun 2006
Location: In a box
Posts: 27
Rep Power: 0 Silicon_Pudding is on a distinguished road
Quote:
Originally Posted by Cerulean
If you're asking about opening a webpage or viewing an image on the web then read my previous post.
os.system("program-name")
launches the program specified by 'program-name', e.g os.system("firefox") would start firefox if it's installed.
If you just want to open an application you don't want os.startfile on Windows at all, as that loads the given file in the application that is associated with it (by default notepad for a .txt file, Windows image viewer for .jpg, etc). Probably not what you wanted.
Is there a method for specifiying the file and a program other than the associated one?
__________________
~ Silicon Enhanced Pudding
"It's magically delicious"
Silicon_Pudding is offline   Reply With Quote
Old Jun 14th, 2006, 11:56 PM   #13
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,099
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
Like I said in my post, os.system executes a system command. So whatever you would type in to the command prompt is what you would use here. I believe in linux, it is the application followed by the filename.

Example:
nano my_script.py
versus
python my_script.py
Sane is offline   Reply With Quote
Old Jun 15th, 2006, 12:16 AM   #14
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 933
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
You could use this code to call os.startfile if it exists on your system, or else call os.system with a specific program to open the file.

import os

if 'startfile' in dir(os):
	os.startfile("/path/to/file")
else:
	os.system("program /path/to/file")
titaniumdecoy is online now   Reply With Quote
Old Jun 15th, 2006, 7:26 AM   #15
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,099
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
Isn't that what I've said twice now? Am I just being confirmed... or ignored? =S !

(Well, I guess yours is a bit different because it actually runs in there, fists raised, looking for the function.)
Sane is offline   Reply With Quote
Old Jun 20th, 2006, 12:14 PM   #16
Silicon_Pudding
Newbie
 
Silicon_Pudding's Avatar
 
Join Date: Jun 2006
Location: In a box
Posts: 27
Rep Power: 0 Silicon_Pudding is on a distinguished road
Quote:
Originally Posted by Sane
Isn't that what I've said twice now? Am I just being confirmed... or ignored? =S !

(Well, I guess yours is a bit different because it actually runs in there, fists raised, looking for the function.)
Thanks for the help. Didn't have access to a computer last weekend
__________________
~ Silicon Enhanced Pudding
"It's magically delicious"
Silicon_Pudding is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:27 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC