LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 04-30-2007, 10:43 AM   #1
Valkyrie_of_valhalla
Member
 
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301

Rep: Reputation: 30
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.
 
Old 04-30-2007, 12:33 PM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,135

Rep: Reputation: 230Reputation: 230Reputation: 230
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.
 
Old 04-30-2007, 01:11 PM   #3
Valkyrie_of_valhalla
Member
 
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301

Original Poster
Rep: Reputation: 30
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?
 
Old 04-30-2007, 03:15 PM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,135

Rep: Reputation: 230Reputation: 230Reputation: 230
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.
 
Old 05-01-2007, 04:00 AM   #5
Valkyrie_of_valhalla
Member
 
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301

Original Poster
Rep: Reputation: 30
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.
 
Old 05-02-2007, 06:23 AM   #6
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,135

Rep: Reputation: 230Reputation: 230Reputation: 230
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.
 
Old 05-02-2007, 09:50 AM   #7
Valkyrie_of_valhalla
Member
 
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301

Original Poster
Rep: Reputation: 30
Oh yeah, I forgot about that... I haven't booted into windows for quite a while now...
Thanks!
 
  


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
command output to text file? meniscus Linux - Newbie 4 10-05-2006 05:29 AM
how to send shell variable data to a text file ginda Programming 7 06-23-2006 05:49 AM
send text to file bash bendeco13 Linux - General 6 11-01-2004 06:26 PM
Send emails to list in text file using RedHat9 MrEase Linux - Newbie 1 04-24-2004 07:35 PM
Piping output to a text file joadoor Linux - Newbie 7 04-19-2002 03:50 AM


All times are GMT -5. The time now is 03:55 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration