473,569 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Automate VLC player in perl?

Srijith B
20 New Member
I want to write a code in perl which automatically opens vlc player and start playing.

I am stuck when I open the vlc player.
I use

Expand|Select|Wrap|Line Numbers
  1. SYSTEM("vlc");
  2.  
But when I execute the lines below this code doesn't not execute.
Is there any other way to open vlc player?

ok, I changed my code
Here is it

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2.  
  3. #exec (vlc);
  4. #print "vlc launched";
  5. $directoryListing = `vlc`;
  6. print $directoryListing;            //opens vlc
  7.  
  8. print "vlc playinng";
  9.  
  10. my @keys = ("%{m}", "{ENTER}");
  11. for my $key (@keys){
  12.  
  13. SendKeys ($key);
  14. }
  15.  
Problem here is once I execute, the statements after print $directoryListi ng; does not work.
Jan 18 '11 #1
6 4750
RonB
589 Recognized Expert Moderator Contributor
You should have received the following error:
Undefined subroutine &main::SYSTE M called at
Perl is case sensitive.

It's system not SYSTEM
Jan 18 '11 #2
chorny
80 Recognized Expert New Member
Do a fork and run vlc in fork. `` waits for program to finish.
Jan 26 '11 #3
Srijith B
20 New Member
I dont want to wait after I run vlc. I want the below statements to execute after the vlc is opened.
what I get is
The VLC will open and a message "[0x9bfa140] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface." appears in the terminal and the program is waiting for vlc to quit. once the vlc quits(CTRL +C or close vlc using mouse) the rest of the statements execute. Btw I tried forking and had no luck.. same result.
here the forking code
Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2. $pid = fork();
  3. if( $pid == 0){
  4. system("vlc");
  5. exit 0;
  6. }
  7. print "vlc playinng";
  8.  
  9.  my @keys = ("%{m}", "{ENTER}");
  10.  for my $key (@keys){
  11. SendKeys ($key);
  12. }
  13.  
  14.  
  15.  
Feb 28 '11 #4
miller
1,089 Recognized Expert Top Contributor
The following example with fork does work for me, however, the script won't exit until vlc is closed.

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2.  
  3. use strict;
  4.  
  5. my $vlc = q{C:\Program Files\VideoLAN\VLC\vlc.exe};
  6.  
  7. unless (fork) {
  8.     system($vlc);
  9.     exit;
  10. }
  11.  
  12. print "Hello world\n";
  13.  
Since you're running on a windows machine though, you have the option of using Win32::Process

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2.  
  3. use Win32::Process;
  4.  
  5. use strict;
  6.  
  7. my $vlc = q{C:\Program Files\VideoLAN\VLC\vlc.exe};
  8.  
  9. Win32::Process::Create(
  10.     my $processobj,
  11.     $vlc,
  12.     "vlc",
  13.     0,
  14.     NORMAL_PRIORITY_CLASS,
  15.     "."
  16. ) or die "Can't Create - $!";
  17.  
  18. print "Hello world\n";
  19.  
The above will start vlc, and continue to Hello World and exit, leaving vlc running.

- Miller
Mar 2 '11 #5
Srijith B
20 New Member
sorry for not mentioning the OS.
I am using Linux ubuntu.
I have a well running vlc automation script in windows.
And yes, I used the same package as the above(Win32::Pr ocess).
But you know that we cant use these in linux.

I am unaware of packages in linux that is to be used.
Mar 3 '11 #6
miller
1,089 Recognized Expert Top Contributor
Well, if all else fails, just use & to start the process as an independent daemon.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl-w
  2. # waitforme.pl
  3.  
  4. use strict;
  5.  
  6. my $log = 'waitforme.log';
  7.  
  8. open my $fh, '>>', $log or die "$log, $!";
  9. for (1..5) {
  10.     print $fh scalar(localtime), " - $_\n";
  11.     sleep 2;
  12. }
  13.  
and the main script

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl-w
  2. # dontwait.pl
  3.  
  4. use strict;
  5.  
  6. my $prog = q{perl waitforme.pl};
  7.  
  8. system(qq{$prog &});
  9.  
  10. print "Hello world\n";
  11.  
- Miller
Mar 3 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3762
by: Stephen Ferg | last post by:
I need to translate some Perl scripts into Python. When I went looking for a tool that would help automate the translation, I was rather surprised that I couldn't find anything. BridgeKeeper, the only real candidate that I could find, is no longer available. There are of course general-purpose parsing packages, but I'm looking for...
1
1921
by: Someone | last post by:
there's a korn shell script that i would like to wrap a perl script around to automate it, as a task i need to do always chooses the same options from this script (it's menu driven). can i somehow redirect my perl scripts stdout to print to this scripts stdin? does that make sense? thanks. sean rowe
0
4718
by: Greg | last post by:
We're looking for CGI/PERL programmer who can help us integrate CamFrogWeb's video conferencing software with our site's user management system (login system) Our site uses customized vesrion of BAC software for our backend, see www.buildacommunity.com
2
3500
by: Santosh | last post by:
Dear all i am created one animated image in Macromedia flash player i want to call it from asp.net page. how i can call it. help greatly apreciated. Santosh Shinde.
2
2176
by: peteinglastonbury | last post by:
I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related. I found a script called BatmoAudiopop.js which opens a pop-up browser window with an audio player when a link is clicked. Basically, it sets the right mime-type depending on the...
4
4441
by: subeen | last post by:
Hi, I am trying to parse a rss similar to the one found here (in example) http://www.feedforall.com/mediarss.htm <!-- Snipped for Brevity --> <item> <title>FeedForAll's Show Tunes and Song</title> <link>http://www.feedforall.com/songs.htm</link> <description>FeedForAll cool show tunes and lyrics. </description>
2
2152
by: mithunmo | last post by:
I am trying to automate the process of filling up the webforms and do a submit . I have the below program written but If I run the program . I get the following error message Can't call method "value" on an undefined value at C:/Perl/site/lib/Win32/IE/Mec hanize.pm line 900. Please let me know your inputs on the same ...
24
3205
by: Peter Michaux | last post by:
I have a Perl script that I want to run as a set-user-ID program. Many OSes don't allow scripts run as set-user-ID. To make this script portable, it seems I need to write a C wrapper program that calls exec or system to give the Perl script the necessary effective permissions. How can I make the C wrapper program secure? or "more" secure? ...
8
4214
by: gajendra98 | last post by:
Hi All I Have installed Active perl in my system and I am new to perl and automation...Could some one tell me how to install the perl modules and how to use those modules with the perl for autmating the website ... it will be very helpful for me to start automation...
0
1423
by: raghavendrap | last post by:
Hello friends, I need help to automate verilog modules. Suppose i have verilog modules ax.v, bx.v, cx.v, dx.v ---------- individual modules, ab.v ----------------- contains instantes of ax.v,bx.v cd.v ----------------- contains instances of...
0
7620
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7684
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7985
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6298
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3666
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3659
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
959
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.