in reply to Running a C Program within Perl.

(I have made this a reply to your original post; to continue the original thread would have indented too far for my taste)

I can run this at the prompt, but putting in the following, /opt/BIPSConnect/bin/rdes, but when I put it in perl code (here is what I am trying to do - Quite simple and nothing complex, until I get this working) ...
#!/usr/bin/perl-Tw use strict; my $cmd_to_run = "/opt/BIPSConnect/bin/rdes"; my @results = `$cmd_to_run`;
I get the following error... /opt/BIPSConnect/bin/rdes: LD_LIBRARY_PATH=:/usr/lib:/usr/ucblib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:/opt/hpnpl/lib:/p01cfg01/harvest/Harvest/lib:/opt/BIPSConnect/bin: is not an identifier

Okay, this is obviously a UNIX (not DOS/Windows) platform, so that eliminates an entire subspecies of problems.

I notice you are running your perl script with taint mode (-T). Are you, by chance, running it setuid, as well? In setuid mode Solaris (under which you appear to be running) closes the executable file and reopens it such that the program sees /dev/fd4 (or fd5, ...) instead of the name of the actual executable as $0, among other things. In taint mode Perl's behavior apropos the environment is somewhat different as well; certain specific variables must be set to known "safe" values (PATH and LD_LIBRARY_PATH come to mind, for example). Take a look at Perl security for more on this topic.

Update: Is it possible that the message you're seeing has something to do with trying to use the Bourne shell syntax,

[ENVVAR=value ...] command

with csh or tcsh, which do not permit this? What is your default shell?

Just asking ...

dmm

Replies are listed 'Best First'.
Re: Re: Running a C Program within Perl.
by basicdez (Pilgrim) on Dec 27, 2001 at 22:29 UTC
    Here is what rdes looks like.
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/BIPSConnect/bin /opt/BIPSConnect/bin/micn_cr2k_bips_test_console /home/w951an6/perl/ph +ase_II/xxx.xml
    does that help in knowing how to execute it?
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/BIPSConnect/bin /opt/BIPSConnect/bin/micn_cr2k_bips_test_console /home/w951an6/perl/ph +ase_II/xxx.xml

      If that's the whole script, then you are missing the shebang line, i.e., #!/bin/sh, without which, Perl will attempt to execute it with your default shell, which (you didn't say) might be of the csh variety, not a Bourne-style (sh-like) shell.

      Try putting a shebang as the first line.

      dmm

        Shebang line does not work either.