custom commands / keyword in command prompt [closed] - windows

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
This has to be a very simple question... but as long as i can remember i've seen special keywords or commands in the windows command prompt which are clearly not system commands like dir cd etc
Today i was reminded of this using node.js and from the command prompt I cd'd into a director and typed "npm install".
My question is simple... how does the keyword/command "NPM" get associated with a corresponding exe or other "command handler"? I would think this is very basic but after searching through the internet, its surprisingly hard to find the explanation.
E.g. how could i associate "stack /overflow" with some kind of process/exe that would be able to parse out the "overflow" variable.

A command line interpreter has a number of built-in functions (your examples of "cd", "dir" etc.). For all other input it:
looks in the current folder
looks in the current PATH folders
to see it finds a matching command with an executable file extension, such as ".exe", ".com", and ".bat". The system wide variable PATH holds a list of folders to search in.
If you write a program called "stack", it will typically be called "stack.exe" in full, and be put wherever your programming environment outputs binaries. Then you can
use cd to navigate to that folder and type stack to call it
use the full path specification from any other folder, such as c:\Users\Documents\MyOwnsoftware\Stack\Release\stack
copy stack.exe into one of the folders that is already scanned through the PATH variable
add the folder containing stack.exe to your PATH.
As you can see, these solutions all comply to the look-up order above.

Related

Windows: File List with Wildcard in filename [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
Anyone can explain to me why? From the screen shot, you can see I have some csv file in the current directory. The command: dir .csv or dir ".csv" is not working correctly. However, anything like: dir **.csv, dir ?*.csv, dir .csv are working. All of them can list the files I am looking for. Why?
In case you are unfamiliar with what dxiv is talking about. Aliasing in PowerShell is when you essentially give a command a nickname. In PowerShell there is no such command as dir, it's only an alias for the command Get-ChildItem.
The documentation for that command is here:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.1
If you read through, you'll see that you need to specify a wildcard as a stand-in for the filename before passing the extension.
Generally speaking, the reason you need wildcards for things is to tell the language you're using that there should be something before it. By typing .csv you are searching for files that are literally called '.csv'. No more, no less. The wildcard in *.csv says that it should look for anything ending with '.csv'.

How to use program name with out specific path in .cmd file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
When I usually type following command in command prompt,
pageant "C:\Users\test\.ssh\id_rsa.ppk"
It have worked well.
But on the other hands,when I make test.cmd file like
pageant "C:\Users\test\.ssh\id_rsa.ppk"
And then double click, it didn't work
buttest.cmd in following script
"C:\Program Files\PuTTY\pageant.exe" "C:\Users\test\.ssh\id_rsa.ppk"
work well.
What is the different between them ?
I guess The path was recognized by cmd.
If someone has opinion, please let me know
If the command doesn't contain an absolute path and isn't an internal command then cmd.exe will find the executable in the current folder and then look in the folders in the %PATH% environment variable. It looks like the current folder in your cmd is C:\Program Files\PuTTY so pageant can be found and execute normally. If you cd to a different folder then it won't work unless the folder exists in %PATH%

W10 CMD forfiles [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Since I had a task where I have to copy recursively files of a nested directory for work, i discovered the forfiles-function in windows cmd.
It worked properly and now I wonder how does the function distinguish between a file and a directory?
If every file had a file extension like .jpg .png .xls or something like that, I could understand it, but some of my files came without extensions, but it still did its job.
As I'm used to linux, I tried to google the sourcecode, but windows applications aren't opensource, so if anybody can explain me, how does it work, it would be very interesting to know.
PS: why does this got downvoted? its a general question
The command will eventually call the Windows FindFirstFile/FindNextFile functions. Those return a WIN32_FIND_DATA structure which may contain a FILE_ATTRIBUTE_DIRECTORY flag. If that flag is not set, it's a file.
Internally there is quite a difference between a file and a directory, and it's no surprise that typical file/directory handling commands know about this. The fact that a file doesn't have an extension (or that a directory is called "directory.jpeg") does not cause any confusion within those commands.
If you check forfiles' "man page" (forfiles /?), you might see that the /C switch gives you access to the #isdir variable, which can tell you the difference: are you dealing with a directory (value:TRUE) or a file (value:FALSE)?

hidden autosave file error: no such file or directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I was editing an emacs file abc, and prior to saving, had a crash. There is now a file .#abc, and I would like to find out what is in that file, to perhaps recover what I was working on.
I know the file is there because when I type
ls -a
it lists
.#abc
However, when I type
more ".#abc"
or simply
more .#abc
I get the error
.#abc: No such file or directory
The same error occurs with cp in place of more.
How do I see what is in that file? Why does ls list it and then other commands can't find the file?
(Is .#abc actually an alias file? If so, how would I know that? And how, nevertheless, do I see the content of it, even if this is only what it is an alias to?)
[Note: I do not want to use emacs to try to find out what is in the file or restore it, because the situation is somewhat more complicated than described: the above is all occurring inside a Time Machine backup, which I need to access because of an emacs autosave overwrite problem on the primary file. I don't want to have the same problem occur on the backup of the autosave file!]
This is all on Mac OS10.8.4.
Whereas autosave files use a tilde ~, lock-files use a dot number-sign .#:
http://www.gnu.org/software/emacs/manual/html_node/elisp/File-Locks.html
Creation of lock-files can be disabled with the following setting:
(setq create-lockfiles nil)
https://stackoverflow.com/a/12974060/2112489

Mac / Unix: overwritten path variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I was starting to type the command export PATH=/newPathAddition:$PATH I think I must have copied in a newline when copying the newPathAddition to paste into the command, because it ran export PATH=/newPathAddition. I know I can manually add things to the path variable, but is there any way to restore it to what it used to be, or find out information about which directories were in the path beforehand? I really don't want to be in a situation in the future where all these commands aren't working on my computer because things vanished from the path that I don't remember.
These changes are local to this one command prompt. Just open another terminal window.
If you need the normal value of $PATH to use in this one specific terminal window, open another one and copy its $PATH value.
If you want changes to $PATH to persist, you need to write a .bashrc file or a .profile file in your home folder with the $PATH-altering commands you wish to use. To revert, take them out.

Resources