in reply to Script which creates 2nd script and runs it

You need to take a close look at your paths, figure out which of the many paths you refer to is the right one, and then make sure you use that one path everywhere.

open (STDOUT, ">$script"); creates the script in the current directory.

system "chmod 755 /export/home/ss/flowstats/config/$date/$script"; chmod's the script in a directory with an absolute path.

system "./export/home/ss/flowstats/config/$date/$script"; runs the script in a directory relative to the current directory.

I'm not sure why you want to create this shell script, however, instead of just using Perl's builtin filetest operators and mkdir. (There's also a chmod.)

Update: For the commands that need to be run externally, you should use system or qx//, as suggested in reponse to your node from yesterday.

Replies are listed 'Best First'.
Re: Re: Script which creates 2nd script and runs it
by Tuna (Friar) on Feb 01, 2001 at 01:40 UTC
    This shell script includes the output of other parts of the code, not just what is between END and END. The resultant shell script will run another program several times, each time with different arguments passed to it.
Re: Re: Script which creates 2nd script and runs it
by Tuna (Friar) on Feb 01, 2001 at 01:45 UTC
    Look at the bottom of the script. I AM using  system. What I'm saying, is as written, it doesn't work. The file script-$date is written, but that's it!
      You're using system to execute a shell script which then executes other commands. My suggestion is skipping the shell script altogether, and using system to execute those commands directly from Perl.

      For example:

      foreach $key (keys %hash) { my $cmd = "$program $key $matrix "; $cmd .= "$path/CISCO_$_.clean " for @{$hash{$key}}; system($cmd) == 0 # system returns 0 on success or die "system '$cmd' failed: $?"; }