Nov 21, 2009

Perl: Exec Or System ? - which is best for this senerio

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > Perl & CGI

Perl: Exec Or System ? - which is best for this senerio

unimatrix
I am writing a script to add submit/add projects to a queue. I don't need a returned result other than it worked or failed. The script will execute a commandline like thisL


'program -b $filename -s $start -e $end -a'

all I need is for that command to be send and if it suceeds return a simple

"This worked"
or
"This failed: here is why ___________".

I am just trying to remember the difference between exec and system() for this task. I've read through the documentation and am still a little confused. It's the first time I've really used PERL in at least four years.

Comment/Reply (w/o sign-up)

yordan
Read your doc carefully.
On unix or Linux shell scripts, "exec" means "execute what I tell you and exit immediately after that".
This means that, in Unix, all the lines after the exec instruction are ignored... ohmy.gif

Comment/Reply (w/o sign-up)

Digital Technic
Use backticks to capture output.

CODE

$output = `program optional_arguments_jere`;


Please note that those are backticks(on QWERTY it's right below the Escape key).

Regards, Digital Technic.

Comment/Reply (w/o sign-up)

crtburn
Use the system() function to execute a program without saving the program's output. The return value of the system() function is the program's exit status or you could check the special $? variable which will have it as well.

The exit value 0 means the program exited successfully and anything else probably means there was a problem. If there was an error then it will be stored in $!.

CODE
system("myprogram --foo $bar") == 0 or die "myprogram failed ($?): $!";
print "myprogram ran successfully.\n";

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : perl, exec, system, senerio

  1. Maximum Number Of Decimal Places In Perl Language
    (0)
  2. Perl Programming Language
    (1)
    Hi, I want to use a big number in perl programming language. Unfortunately, my perl software does
    not support "BIGNUM". Is there another way to replace "BIGNUM" to solve my problem. Thank you for
    your feedback. ....
  3. Just Learning Perl
    (6)
    Okay so I've decided to learn PERL. As I am VERY burned out on PHP after making an online
    hacking game in it and working on it for a month after release. Now that its almost done other than
    maintenance. I'm VERY good at php now. However I tried to do C and quickly thew my hands up
    (maybe too quickly). So I decided to learn PERL just to learn it. I'm curious, what are some
    practical uses for PERL (online. but more importantly offline/background/not used by public), does
    perl use the same if, else, while and the like as PHP? Thanks....
  4. Simple Perl Script...
    (1)
    I want to know the perl path to include at the beginning of the file....so that my perl scripts will
    run properly... Or is it ok to make a cgi-bin directory and put my perl scripts in it? Any reply is
    appreciated. cpn....
  5. Using Perl For Newsletter Subscription
    (1)
    so I'm interested in adding a newsletter subscription to my website for visitors that are
    interested. I configured the cgi script, now I'm only wondering how to use the smtp feature with
    astahost.. would 'localhost' suffice, or will I be needing to get smtp auth? thanks for the
    help /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />....
  6. Create Easily Modifiable Html Templates For Use In Your Perl Cgis
    (0)
    Copied from http://www.tutorialized.com/tutorial/Ace-P...te-Creator/3364 QUOTE Hate having
    to place all the print statements in your program and having to escape all those quotes? Would you
    like to give the ability for people who don't know how to program in perl to customize the
    output of your cgis? Templates are the answer. Here's how it works. Take any html file and
    anywhere you place in(variable), it gets replaced with $in{'variable'}. For example, if you
    have $in{'name'} = 'bob' and an html file that has: Name: in(name) T....
  7. Help Needed To Create Login Script With Perl/cgi
    Need Script (21)
    Have a format in mind and have a good idea how it works. So here what I need: step 1::: person must
    register: create handle // enter password // enter password // enter email : it then takes the
    person to acsepted page or reject per reason page. step 2::: login page: enter handle // enter
    password : takes them on it to the site of their control pages for each handle controls their own
    pages yet all pages interacts with the others. or bad password re login page. Have the page
    designed already have the script in html lang but one can create a password on the html page but....
  8. Strange Perl Behavior
    (4)
    I have been working on a strange problem I've been having. I am reading a series of large files
    (50 mb or so) in one at a time with: @lines = ; or (same behavior with each) while( ){
    push(@lines, $_); } The first time I read a file it will read into the array in about 2 seconds.
    The second time I try to read a file in (the same size) it takes about 20 seconds. Everything is
    declared locally inside the loop so, everything is leaving scope. I am not sure why it is taking so
    much longer the second time. I need to read the entire file in because I am doi....
  9. Best Place For Information On Perl
    I would like to learn Pearl! (8)
    Hello, I would like to learn Pearl so that I can start working with CGI scripts so that I can in
    order to build a more inventive/interactive and dynamic website. I would like if someone could
    point me to a site were I can not only learn Pearl, but also download software to help devlop code.
    (An IDE of some type.) Thanks, Tim....
  10. Sockets And Perl
    for a chat script (1)
    Okay, I was trying to write a chat script for perl with tk for the GUI on active perl 5.8. But
    whenever I use the $socket->listen() function to connect to the client, the script always hangs on
    me. Any ideas as to how to avoid this problem (I've tried numerous codes including the one from
    webmonkey).....
  11. Simple Problem W/ Perl
    I can't get this hello world script (5)
    Here's my code: CODE #!/usr/bin/perl # print "Content-type: text/html\n\n"; print "Howdy,
    world!"; I saved it in my cgi-bin with 777 permissions and It goes; QUOTE Internal Server
    Error The server encountered an internal error or misconfiguration and was unable to complete your
    request. Please contact the server administrator, webmaster@supper.astahost.com and inform them of
    the time the error occurred, and anything you might have done that may have caused the error. More
    information about this error may be available in the server error log. Additiona....
  12. Perl : Help
    How to run command lines (4)
    Hi there , I would like to have help with Perl. When I make a program and I run it , it close
    instantly after it is done. So how could I keep it open after his execution ? And also , where can
    I find Perl command lines ( if it exists for sure ) Thanks everyone , Happy new year. Mathieu_021....
  13. Does Anyone Know To Use Movabletype (perl)
    (6)
    I can't fit my long title in the topic title so cont..impeccable knowdledge of Moveabletype 2.xx
    it's like so foriegn to me..I'm really new at this but I'm trying to make a blog and
    I'm so clueless..any help? thanx in advance....
  14. Perl Script
    (0)
    Hey everyone, got a problem with a Perl script I'm trying out. In my Perl script, I have the
    user input a number to dynamically display a number of text form fields in which they enter figures.
    At the bottom, there will be a button to give the sum of all the numbers in the text
    fields--that's where I'm stuck, I got the text boxes to show up alright, but that's
    about it. I thought I might use JavaScript, but that didn't turn out to well. I was thinking of
    using arrays for the name referencing in the javascript part, but I couldn't figure that out e....
  15. What Is Perl?
    (11)
    I have been looking high and low for a good domain service, and most places I have checked have Perl
    as a feature (including this one). What is Perl? It is included in the same info space that stuff
    like cPanel is put. But most importantly, how can Perl help me? If it can't, why do they
    advertise the ability to use it everywhere?....
  16. Perl Text Safety
    (1)
    How do you make inmput from a textarea html and perl safe?? like remove the / the tabs (\t) and
    linebrakes (\n) like the javascript escape command (so i can store it into a textfile that reads
    line by line inforation and uses /t as a seporater (I could use someting else as a seporater if that
    would make more sence )) Thanks for all your sujestions....
  17. Crypto Program
    A perl "script" to protect data (0)
    If you'd like to protect you doc without the standard program and algorithms you'll fide it
    useful, Now the only big problem is the ARRAY pased to the subs, in fact I can't pass 2 @ at
    the same Sub so I have to use a global array(@plus) in the subroutines, SomeOne knows if is it
    possibile to pass 2 @ to a sub? if yes how? CODE #!/usr/bin/perl #************Random Signature
    V1,0******************# #* CodeName: Crypto v1.7 alpha                     *# #* Coder: K22 -
    www.klakice.astahost.com;         *# #* Date: 07/11/2004;                                ....
  18. Perl, the hacker language?
    (6)
    For you why many times we associate Perl to the hacker's world?for many exploit write in perl or
    for the flexibility of the Lang, what do you think about? For me, Because in perl the operation on
    the strings and with the socket are powerful as in c but perl is simpler to write IMHO Byez &
    'njoy....

    1. Looking for perl, exec, system, senerio

See Also,

*SIMILAR VIDEOS*
Searching Video's for perl, exec, system, senerio
advertisement



Perl: Exec Or System ? - which is best for this senerio

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com