views:

407

answers:

3

I'm trying to automate a process on a remote machine using a python script. The machine is a windows machine and I've installed CopSSH on it in order to SSH into it to run commands. I'm having trouble getting perl scripts to run from the CopSSH terminal. I get a command not found error. Is there a special way that I have to have perl installed in order to do this? Or does anyone know how to install perl with CopSSH?

+4  A: 

I suspect CopSSH is giving you different environment vars to a normal GUI login. I'd suggest you type 'set' and see if perl is in the path with any other environment vars it might need.

Here is some explanation of setting up the CopSSH user environment. It may be of use.

SpliFF
ActiveState perl is installed and shows up under the windows path (My Computer -> Properties -> Environment Vars.) but when I run the set command perl isn't there. Would you be able to tell me how to add it?
cmmacphe
i've added a link to my answer, it talks about an environment file and some other specifics of the copssh setup.
SpliFF
I've checked out that link you mentioned. I'm just unsure of what I would add to the environment file. Probably something like PERL_HOME=C:\Perl\ ?
cmmacphe
yes but you should also set PATH to include C:\Perl\. Come to think of it, if the copssh login is actually a cygwin environment your paths may need to be UNIX-style, ie /c/windows/system32:/c/Perl . Cygwin may allow either or may require backslashes to be escaped (C:\\Perl\\). Can't remember off the top of my head.
SpliFF
which PATH do you mean, the windows variable or the cygwin variable? If you mean the windows PATH then I've already added it to that one. As for the path styles I think cygwin does allow for both types of paths.
cmmacphe
the only one that matters is the one set at the time you login. As to where that is being set I cannot say however if you can find CopSSH's login script (probably something in the 'user home') you can override PATH at any time using export PATH=$PATH:/path/to/perl. There are other options too like giving the full path to perl (as Chas Owens has said) or creating a shell script to run in place of perl that does these things. However bash scripting is too complex a topic for this comment. Suffice to say your login shell does not know where 'perl' is - so you must tell it.
SpliFF
To clarify.. It's almost certainly CopSSH and/or bash (the shell) that's setting up your environment in this case. It can probably be set system-wide and per-user. The specifics will require you consult the manual. Arguably it should be reading in the windows environment (you did restart CopSSH after you changed it right?). Either way you need to locate the relevant copssh configuration files. On linux the system-wide PATH is often set via a file called /etc/profile (system) or [home dir]/.bashrc (user), but then cygwin/copssh is not real unix and may have its own ideas.
SpliFF
+2  A: 

Are you using ActiveState or Strawberry Perl? What error messages are you getting? You may find the answers to How do I run programs with Strawberry Perl helpful.

Chas. Owens
I'm using ActiveState perl. I get the error message command not found.
cmmacphe
Are you trying to run the perl script directly or are you trying to say "perl script.pl"?
Chas. Owens
perl script.pl is what I'm trying to run. I just can't seem to get perl added to the path in copSSH
cmmacphe
try giving the full path to perl (e.g. c:/perl/perl.exe /path/to/script.pl or /cygdrive/c/perl/perl.exe /path/to/script.pl).
Chas. Owens
+2  A: 

I just realized CopSSH is based on Cygwin which I think means paths would have to be specified differently. Try using, for example,

/cygdrive/c/Program\ Files/My\ Program/myprog.exe

instead of

"C:\Program Files\My Program\myprog.exe".

BTW, the following CopSSH FAQ might be applicable as well: http://www.itefix.no/i2/node/31.

Sinan Ünür