Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What is a difference between Linux and Windows shell access tool?

In some programming languages (web languages from my experience) when you need to execute some command - you need to specify path to cmd.exe in Windows, while in Linux you access the shell right away... What and why is the difference? What exactly do languages hit in both systems when you run some sort of os.execute() command?

EDIT: This is rather theoretical question and is not related to programming practices. I do realize that this might not be simple to explain topic, so link or showing the right direction to dig in will do the trick too.

Here's one of examples in coldfusion (which is one weird freaky one I should say):

<cfexecute name="C:\Windows\System32\cmd.exe" arguments="echo Hm" />
share|improve this question
2  
These questions are, together, overly broad. –  RedGrittyBrick Aug 17 '12 at 13:48
    
@RedGrittyBrick I am interested in topic, but I don't posses enough knowledge on subject and looking forward to get a tip where to start digging. –  Ruslan Osipov Aug 17 '12 at 13:51
    
"Why is the difference" is essentially unanswerable. The people who made those decisions probably didn't publish their reasons. We can speculate, but this is not the forum for that. I always start with Google. You could also try SU chat. –  RedGrittyBrick Aug 17 '12 at 13:53
    
I guess why is the wrong question indeed. But actually - what does language's os.execute() hits in every OS? Yeah, I guess the question doesn't make a lot of sense itself... –  Ruslan Osipov Aug 17 '12 at 13:59
    
Please give specific examples of those languages. And see my counterexample of python. –  Henk Langeveld Aug 17 '12 at 14:09
show 1 more comment

closed as not constructive by RedGrittyBrick, EBGreen, MaQleod, Indrek, Canadian Luke Aug 17 '12 at 20:58

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

up vote 3 down vote accepted

Well I'll try to be simple (broad subject)

The difference between windows and linux is clear, the core is not the same, I won't go in the history direction (check on wikipedia if you're curious ;), but linux tend to prefer script because that's allow the user to custom the installation or the OS as he want, windows use .exe that modify the register key to execute programme.

As for why you need to type the whole path to execute windows exe it's quite simple (I won't go in a deep boring explanation), windows don't really use the global variable (easy explaination : the registerkey don't really need this to operate the exe), while linux tend to love global variable, in fact you can easilly add global variable in linux that point to your script.

So when you want to run a linux script you type the cmd (pointing to the global variable containing the path), and then the magic goes. For windons you are the global variable so you need to define the path to the exe to run. You can create your own global variable in windows and use it like linux if you want, but personnally don't like doing that.

Hope you understand a little better the principle.

share|improve this answer
    
I guess I did not understand the question itself to begin with... Thank you all for the input on such a clumsy question - I do understand it a bit better now. –  Ruslan Osipov Aug 17 '12 at 14:32
    
no problem, we're here to help each other :) –  Anarko_Bizounours Aug 17 '12 at 14:33
add comment

They're completely different platforms and most commands executed through their respective shells would be incompatible, with the exception of Cygwin on windows, which uses the same commands as a linux shell.

As a rule of thumb, try and avoid using OS-specific calls whenever possible.

share|improve this answer
    
Uh, perhaps question is not clear enough - I did not ask what to do, I asked why and how this is happening. –  Ruslan Osipov Aug 17 '12 at 13:42
    
@pyrate Ah may have misread slightly, I don't fully understand what you're asking though - what do you mean by "in linux you access the shell right away" as I see it both systems function the same in that regard. –  9point6 Aug 17 '12 at 13:52
    
I mean in Linux you do execute(boom), while in Windows you usually do execute(C:\Windows\System32\cmd.exe boom). –  Ruslan Osipov Aug 17 '12 at 13:55
    
Carefull there wygwin don't use the same command as linux shell, it's a shell emulator! RedHat created it allow it's product to be portable on windows plateform (but it's true you can run cmd, but cygwin will convert the cmd in dos cmd that'll lunch .bat or .exe ;) –  Anarko_Bizounours Aug 17 '12 at 14:28
    
@pyrate - it depends on the command, in windows commands like 'dir', 'echo' and 'cd' exist only within the cmd executable so from a shellExec point of view they might not exist, whereas linux might handle this differently. As for requiring the whole path to cmd.exe, this shouldn't be necessary if it is in the user's PATH variable (which it should be) unless the environment your application runs in uses a different value for PATH –  9point6 Aug 17 '12 at 14:37
add comment

From within python I can say:

>>> rc = os.system('echo yes')
yes
>>>

This will work the same under Windows, Linux or any Unix variant.

I think that the phenomenon that you observed is specific to the portability of the language in question.

And note that the subset of command strings that would produce identical results is very limited. Windows and Unix have very few commands in common.

share|improve this answer
    
Added an example. –  Ruslan Osipov Aug 17 '12 at 14:12
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.