12 Replies Last post: Apr 23, 2013 6:51 PM by Andriy Bazanov  
Alex Oshchepkov Newbie 52 posts since
May 4, 2011
Currently Being Moderated

Apr 20, 2013 7:23 AM

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?

Andriy Bazanov Master 3,906 posts since
May 28, 2010
Currently Being Moderated
Apr 20, 2013 2:33 PM in response to: Alex Oshchepkov
Re: How to run commands in Command Line Tool Console?

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).

Andriy Bazanov Master 3,906 posts since
May 28, 2010
Currently Being Moderated
Apr 20, 2013 5:03 PM in response to: Alex Oshchepkov
Re: How to run commands in Command Line Tool Console?

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

Andriy Bazanov Master 3,906 posts since
May 28, 2010
Currently Being Moderated
Apr 21, 2013 3:50 PM in response to: Alex Oshchepkov
Re: How to run commands in Command Line Tool Console?

Yes, it should.

 

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

Elena Shaverdova JetBrains 192 posts since
Oct 13, 2010
Currently Being Moderated
Apr 22, 2013 7:10 PM in response to: Alex Oshchepkov
Re: How to run commands in Command Line Tool Console?

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?

Andriy Bazanov Master 3,906 posts since
May 28, 2010
Currently Being Moderated
Apr 22, 2013 7:18 PM in response to: Elena Shaverdova
Re: How to run commands in Command Line Tool Console?

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) ?

Alexey Gopachenko JetBrains 1,461 posts since
Aug 22, 2002
Currently Being Moderated
Apr 22, 2013 7:37 PM in response to: Andriy Bazanov
Re: How to run commands in Command Line Tool Console?

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.

Andriy Bazanov Master 3,906 posts since
May 28, 2010
Currently Being Moderated
Apr 22, 2013 8:10 PM in response to: Alexey Gopachenko
Re: How to run commands in Command Line Tool Console?

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).

Andriy Bazanov Master 3,906 posts since
May 28, 2010
Currently Being Moderated
Apr 22, 2013 8:08 PM in response to: Andriy Bazanov
Re: How to run commands in Command Line Tool Console?

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).

Andriy Bazanov Master 3,906 posts since
May 28, 2010

More Like This

  • Retrieving data ...