How to run commands in Command Line Tool Console?

OS: Windows 7.

Why when I try to run some command that are avaliable through command line I got "Can not run command. ..... The system can not find the file specified"
Is it possible to run external commands via this tool on windows?

0
12 comments

Hi Alex,

What kind of commands? Please provide an example.

If this command is internal for (only available in) cmd.exe (like "start", "dir" etc, then NO -- you cannot run them (unless Command Line Tool has its own implementation/emulates it). External commands (like "xcopy", "ping" etc) can run just fine since they are implemented as separate executable files.

But you can execute cmd.exe in Command Line Tool and then you will be able to use those "start", "dir" etc internal commands, since you will be running them via cmd.exe (do not forget to use "exit" when done -- cmd.exe is still a program).

0

I mean commands like external framework utilities  for example "npm install".

I know that I can run "cmd" And there execute what I want. Running via cmd has some drawbacks, for example there is no auto scrolling to the end of the output of executing console program and command history doesn't work as well.

And actually I've run into other more strage issues when running tools via "cmd" in Command Line Tool. (for example node programs can not use process.stdin raw mode, jitsu (nodejisu hosting deploy tool) is not working correctly either.

What is way to add internal tools that can be run via Command Line Tool?

0

If IDE cannot find such command automatically from PATH environment variable .. then you can create an alias which should work (at least it works OK for me)

1) Settings | Command Line Tool Support
2) Create new entry of "Custom" type
3) Fill all required fields
screen01.png
4) Execute new command

For example, "npm ll -g" will show me correct output

screen02.png

P.S.
http://youtrack.jetbrains.com/issue/WEB-1870

0

Thanks will try this approach. But should IDE lookup in the PATH env var?

0

Yes, it should.

I do not know why it cannot find npm in this case -- maybe dev can answer you this.

0

Hello!

IDE looks into PATH. But there is known Windows issue that IDE can't get changes in PATH without restart. Is it your issue?

0

Not in my case:

command: pear -- PhpStorm cannot find it (but in is in the PATH)
command: pear.bat -- works fine

command: npm -- PhpStorm cannot find it (but in is in the PATH)
command: npm.bat -- cannot find as well

RE: npm -- maybe, just maybe, it's because I do have 64 bit installation of node.js .. and since IDE is 32-bit .. it may have issues finding it (not sure at all, just an idea)

P.S.
Is there a way that allows to dump PATH variable from within IDE (command line tool in paricular) ?

0

It seems it may be a bug. I'm too on Win 7 x64.

0

Well its being a looong time for me since I used any windows, but AFAIR

you all are forgetting about %PATHEXT% variable - windows cmd appends all included extensions to your "command" - that's why "pear" can be used to run "pear.bat" in cmd.

I'm not sure wether we want/should use or emulate that behavior within IDE - feel free to submit a request - but current one is quite an expected and logial.

0

I'm fine with pear vs pear.bat. I mean -- I do understand why it happens (IDE searches for exact file name, without utilizing PATHEXT or just simple .exe/.bat options). Having IDE to look for alternate names (at least on Windows: EXE/BAT) would definitely be beneficial.

But PhpStorm is still unable to find npm.bat


My PATH as seen from cmd.exe (when PhpStorm is running)
screen01.png

My PATH variables from "My Computer | System Properties | Advanced | Environment variables" (Windows 7 x64 SP1 Ultimate ENG)


User variable section:

C:\Users\Andriy\AppData\Roaming\npm



System variables section (after replacing ";" by "\n" in text editor):

E:\Projects\php
E:\Projects\pear
%SystemRoot%\system32
%SystemRoot%
%SystemRoot%\System32\Wbem
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\
C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\
C:\Program Files\Microsoft SQL Server\100\Tools\Binn\
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\
C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\
C:\Program Files (x86)\EaseUS\Todo Backup\bin\x64\
C:\Program Files (x86)\Java\jre7\bin
E:\Projects\nodejs\



P.S.
Apparently on my work computer I have nodejs installed in custom location (E:\Projects\nodejs\) while at home I do have it at default C:Program Files\nodejs (64 bit installation). In any case -- IDE cannot find it in both cases.


But in any case: I personally do create custom tool for any of such commands -- does the job for me. I just have not tried it beyond basic yet (talking about npm here).. so not sure if it will install/update packages properly (but it can see *globally* installed packages fine so far).

0

Actually, screw that .. I made a mistake :_|

I'm used to the fact that every tool installed via PEAR will be  *.bat on Windows. With nodejs .. it's actually .bat for one file and .cmd for the actual npm -- and npm.cmd works fine (IDE can find and execute that).


I guess filling a ticket about checking for at least .exe/.bat/.cmd on Windows is good idea (as it should do the job in majority of cases).

0

Please sign in to leave a comment.