jfroebe has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I know this must be something simple, but I can't quite see it.

my $my_DIR = dirname("$my_FILE"); my $my_tmp_file = basename("$my_FILE"); my @my_output = `cd $my_DIR; $my_SCCS edit $my_tmp_file`; print "<h2>@my_output</h2><br>\n"; my @my_output = `echo "cd $my_DIR; $my_SCCS edit $my_tmp_file"`; print "<h2>@my_output</h2><br>\n";

Produced the following output:
===========

"interfaces2.dat" [Read only] [Incomplete last line] 68307 lines, 2045 +312 characters (262672 null) cd /data; /usr/ccs/bin/sccs edit interfaces2.dat
==========

It is running edit interfaces2.dat and skipping the sccs entirely. The edit command is being picked up in /usr/bin/edit (text editor).

I did find this but I get the same result of skipping the sccs.

Running the script from command line executes fine. So something in the environment but don't know what.

Any ideas?

Jason L. Froebe

No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Update

If I hardcode the /usr/ccs/bin/sccs, it works fine. So $my_SCCS isn't being resolved before execution.

my @my_output = `cd $my_DIR; /usr/ccs/bin/sccs edit $my_tmp_file`; print "<h2>@my_output</h2><br>\n";

Unforunately, hardcoding sccs would be a workaround and not a solution as it will be on several machines and there is no guarantee that it will be in /usr/ccs/bin or that we will be on solaris (could be using the free cssc clone of sccs).

Replies are listed 'Best First'.
Re: calling sccs from cgi-bin script
by sgifford (Prior) on Apr 23, 2004 at 22:00 UTC

    Well, first, try printing out the command before you run it; that way you make sure you're running what you think you are.

    Second, check errors (ie check $? to see if the command in backticks succeeded). You can look in your error log to see what error is being printed; probably that will be a big clue to what's going on. If you can't get to your logs, you'll want to capture the error output of the command; something like:

    my $cmd = "(cd $my_DIR && $my_SCCS edit $my_tmp_file) 2>&1`;
    ought to do it.

    Third, the most likely problems are your $PATH environment variables and permissions.

    Good luck!

      Hi sgifford,

      thanks for the reply! Unfortunately it produces the same... the edit executes and not the sccs. If I hardcode the sccs, then it works.

      No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

        Print out the command before you execute it. If that command doesn't contain sccs at all, then the problem is simply that the variable is set wrong. That problem isn't in the code fragment you posted, and should be straightforward to find.