Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-30-2007, 10:43 AM
|
#1
|
Member
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301
Rep:
|
in Pascal: how to exec a program, discard text output or send to text file
I'm trying to create a program in windows that executes mplayer.exe to play a file, and either discards the output (an equivalent to Linux's "mplayer music.mp3 > /dev/null") or sends it to a file.
What I've tried so far, is this test program:
Code:
Program test;
uses dos,crt;
begin
clrscr;
exec('mplayer.exe',' mymusic.mp3 > logfile.txt');
end.
It plays the file, but it displays a series of info on the screen.
Now, if I open a command prompt and enter "mplayer.exe mymusic.mp3 > logfile.txt", it does exactly what I want to: sends all that info about the mp3 to logfile.txt, without displaying anything on the screen.
In the big picture: I want to write a guitar tuning/learning program, that uses mplayer to play the sounds, and that's why I want it not to display anything.
So, how can I play the file, without recieving any text output from the program? (either mplayer, or if anyone can suggest another command-line GPL-ed version wav/midi player)
If anyone has any other ideas on how I can do this (besides coding the media player program my self, as I don't have enough skills to do that), that will be also welcomed.
Thanks for reading, and sorry for the newbie question. Any info/suggestion is welcomed.
|
|
|
04-30-2007, 12:33 PM
|
#2
|
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,466
|
Hi
I remember a bit about DOS but I'm good at forgetting. I think devices was name and : - so maybe try:
exec('mplayer.exe',' mymusic.mp3 > nul:');
Think there was a null device, but i'm not sure the name was "nul:".
Edit:
Was not so good at forgetting after all
Quote:
Microsoft Windows XP [Versjon 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corporation
C:\Documents and Settings\Guttorm>echo test > nul:
|
No output 
Last edited by Guttorm; 04-30-2007 at 12:38 PM.
|
|
|
04-30-2007, 01:11 PM
|
#3
|
Member
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301
Original Poster
Rep:
|
Thanks for the quick reply.
Indeed, it is "nul:". Thanks for telling me about it, it's good to know I won't have to complicate my program with useless textfiles.
It works ok from a command prompt, but, as with the output from a file, doesn't work within the program.... It still outputs the text to the main screen...
I guess I got the exec function wrong? It seems to ignore the "> whatever " bit at the end...
Any ideas on this?
|
|
|
04-30-2007, 03:15 PM
|
#4
|
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,466
|
Maybe
exec("mplayer.exe mymusic.mp3 > nul:");
I don't know why it was split up?
edit:
I think I recall something like
exec(getenv("COMSPEC")+" /c "+args)
Good luck with the program!
Last edited by Guttorm; 04-30-2007 at 03:25 PM.
|
|
|
05-01-2007, 04:00 AM
|
#5
|
Member
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301
Original Poster
Rep:
|
Thanks, I half-got it now...
It's split in two because the syntax is:
exec('program name','arguments to be given to program');
Tried the first thing you said, aka put parameters in first string, leave second string empty, but it doesn't even play the song that way.
Tried the second, like this:
exec(getenv('comspec'),'/c mplayer.exe song.mp3 > NUL:');
Now the part that I don't understand is that under freepascal, it works correctly: it plays the song without displaying anything. But compuled with turbo pascal, it still shows what mplayer displays...
Anyway, I'll just compile it with freepascal. I hope it behaves ok in the program as well.
Thanks again.
Edit: Another noob question, no sense in opening a new thread for this:
Can I make it run in full screen mode directly, without having to press alt+enter when the program runs? Or modify the terminal window's size from within the program?
The highschool manuals just don't give enough info... :|
Last edited by Valkyrie_of_valhalla; 05-01-2007 at 04:25 AM.
|
|
|
05-02-2007, 06:23 AM
|
#6
|
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,466
|
Hi again
I don't know how to set fullscreen within the program. But if you make a shortcut to the exe-file, you can right click it, select properties, and then in the "Options" tab, you can chose to run it in fullscreen.
|
|
|
05-02-2007, 09:50 AM
|
#7
|
Member
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301
Original Poster
Rep:
|
Oh yeah, I forgot about that... I haven't booted into windows for quite a while now...
Thanks! 
|
|
|
All times are GMT -5. The time now is 12:55 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|