Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to provide a variable in the shell.run command?

Status
Not open for further replies.

shuma

IS-IT--Management
Nov 26, 2009
6
AU
Hi All,

My javascript needs to execute shell commands and i need to pass a path as a variable to the command.

//the value to variable 'Project' is read from user
mypath= "oShell = WScript.CreateObject( "WScript.Shell" );
oShell.Run( "command.com /K svn log -v mypath");

Of course this last line does not work because i am putting the variable 'myproject' inside the quotes, how am i supposed specify the variable ?

thank you in advance.
 
>oShell.Run( "command.com /K svn log -v mypath");
[tt]oShell.Run( "command.com /K svn log -v " + mypath);[/tt]
 
I tried that initially but that doesn't work.
Only works if mypath does not have a + Project, it seems like shell.run cannot concatenate.
 
>it seems like shell.run cannot concatenate.
So you say. If that were true, we would have a lot more to keep in mind to start using a language.

It is related to your understanding of how to make a commandline runs. If you've an incomplete understanding in that regard, concatination does not help you much.
 
wow! so much arrogance einstein!
IF we were all like you, we wouldn't be posting anything here now would we?

I had to put the svn command into a .bat and then run that. that worked.
oShell.Run("cmd /C d:\\CR_temp"+"\\"+Project+"\\svnlog_users.bat",1, true);
 
So much arrogance? You say? If I have to put the root cause of the problem, it would appear indeed arrogant. The truth itself is arrogance, mind you.
 
You create a WshShell object whenever you want to run a program locally, manipulate the contents of the registry, create a shortcut, or access a system folder. The WshShell object provides the Environment collection. This collection allows you to handle environmental variables (such as WINDIR, PATH, or PROMPT).

OMFG you can actualy make a useres machine edit its onwn registry & run commands localy.
no wonder Windoze machines are so susceptable to hacking
 
Looks like it's XMas time :)

- shuma: put an alert statement before que Shell.Run to see what you're passing as the argument and you will see what tsuji says

- IP Guru: you will get a security warning before executing it in a standard configuration. You could do the same with a Linux and an applet

Cheers,
Dian
 
- IP Guru: you will get a security warning before executing it in a standard configuration. You could do the same with a Linux and an applet
Interesting
How would i get a linux system to execute a command from javascript function in a web page (sounds v insecure but at least it would only have user permissions) Downloaded apps do not have the execute bit set & cannot be run without active envolvement ( at least thats what i understood so far).

I know IE would give a warning in default but Doze users seem to be programmed to accept anything & everything without thinking, the more technicaly minded then turn off the warnings :-(
 
Well, conceptually you can do the same with an ActiveX control or with an Applet. Of course there are security settings around, generally you will only allow signed elements, but who knows, each user is a differente world

Cheers,
Dian
 
I do not think ActiveX can be run on linux systems
Java Applets should not b able to access the host machine so I guess thay just leave the eng user to download a programm, set the X bit & run manualy.

that does tend to slow them down somewhat & stop them totaly trashing their system ( unless thay have root permissons of course)
 
This is basically a windows scripting host's question. It is also an activex wscript.shell related. Running on linux is normally not within the scope. Besides, I don't understand where the quotes come from. Maybe it should be posted to this thread at all.
 
I just expressed my concern that something this dangerous can be achived on a windows client.

The quotes were from later posts suggesting the same could be done to a linux box which i found supprising & wanted to understand better
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top