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

Hi monks,

I have downloaded secure crt and i would want to run it inbetween my perl file execution.
$crtdir="C:\\Program Files\\SecureCRT 3.0\\"; chdir $crtdir; system ("securecrt xyz.vbs");
its shouting that securecrt is not an internal/external command , what can be the reason.

Old monk

Retitled by Steve_p from 'any problem with the system'.

Replies are listed 'Best First'.
Re: Problem using system to call securecrt
by ZlR (Chaplain) on Feb 07, 2005 at 12:37 UTC

    Did you try using the full path in the system call ?
    Try doing :  system ( "$full_path_to_exe", "xyz.vbs" )

    One more thing : you don't need to write the path with \ in perl .
    You can say :
    $full_path_to_exe =" C:/Program Files/SecureCRT 3.0/securecrt.exe"

    Update : Well, sorry : now i see that your problem is with the space in "Program Files" . See this 421595 where bart gives this solution :

    my $prog = "c:\\program files\\agent\\agent.bat"; system(qq("$prog"));

    ZlR

      No, the unquoted space is only a problem for (single-argument) system. chdir has no problems with spaces:
      C:\>perl -e "chdir 'c:/documents and settings'; system 'dir';"
      lists the contents of C:\Documents and Settings.

Re: Problem using system to call securecrt
by Realbot (Scribe) on Feb 07, 2005 at 12:56 UTC
    Try to remove the last backslash
    $crtdir="C:\\Program Files\\SecureCRT 3.0";

      Also remember that windows has the tilde, which is nice for situations where spaces in filenames can become problems:

      my $crtdir = "C:\\progra~1\\secure~1\\";

      Update: Gellyfish is right -- it is a good idea to verify. But this is moot in light of ikegami's post.

      /renz.
      "The term clinical depression finds its way into too many conversations these days. One has a sense that a catastrophe has occurred in the psychic landscape." --Leonard Cohen.

        You may not want to blindly do <first six chars of file or dir name>~1 but check using dir /x what the shortened version would be.

        /J\

        No need, Perl (and chdir specifically) can handle long file names.
Re: Problem using system to call securecrt
by FitTrend (Pilgrim) on Feb 07, 2005 at 13:35 UTC

    For reasons that I can't explain (other than possible win32 environment variables), I've had to launch window specific files such as .bat, .cmd, and some .exe files like the following:

    if($^O=~m/Win32/) { $winnt = `echo %SystemRoot%` ; chomp($winnt); } system ("$winnt\\system32\\cmd.exe","/c [ABSOLUTE_PATH_TO_BAT_CMD_OR_S +OME_EXE]");

    who know's maybe it holds true for .vbs files.

Re: Problem using system to call securecrt
by ikegami (Patriarch) on Feb 07, 2005 at 15:59 UTC
    Did you check if chdir succeeded?
    chdir $crtdir or die("Can't change to SecureCRT's dir: $!\n");
    Some versions of Windows didn't like a trailling backslah in directory names. You should try removing it.