Page 1 of 1 1
Topic Options
#200539 - 2010-11-08 08:55 PM quoting
HeyDan Offline
Fresh Scripter

Registered: 2010-10-29
Posts: 14
Loc: Bangkok, Thailand
Hi again,

I am using runnas to run a kix script. I have of course quoted the whole command line (that runnas is to execute), but I am wanting to pass a file name to the kix script, and that needs quoting too...

How is this done?

Example: runnas.exe /user:joe "KIX32.EXE kixScript.kix $passedFile=C:\something or the other.txt"

I have tried quoting the command (sent to runnas) in single quotes and it doesn't like that, and kix doesn't like it's parameters quoted in single quotes either.

Is there a way to do this? Or do I need to mess about with a temporary file to pass the name of this file?

Cheers,


Hayden

Top
#200540 - 2010-11-08 09:00 PM Re: quoting [Re: HeyDan]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
If you wrap the part that requires the quotes to be passed on to runas between single quotes then all should be fine.
Kix does not care if you feed it single or double quotes as long as you match them in pairs.

Eaxmple code:
 Code:
runnas.exe /user:joe '"KIX32.EXE kixScript.kix $passedFile=C:\something or the other.txt"'
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#200541 - 2010-11-08 09:42 PM Re: quoting [Re: Mart]
HeyDan Offline
Fresh Scripter

Registered: 2010-10-29
Posts: 14
Loc: Bangkok, Thailand
OK,

Here is a kix script:

 Code:
? $pa


and here is my first attempt:

 Code:
runnas.exe /user:bob 'kix32.exe s.kix $pa="spider web"'


results in:

 Code:
RUNNAS: The system cannot find the file specified.


So I try:

 Code:
runnas.exe /user:bob "kix32.exe s.kix $pa='spider web'"


results in the kix script saying:

 Code:
'spider


and then an error something like:

 Code:
Error: Failed to find/open script: web'

Top
#200542 - 2010-11-08 09:43 PM Re: quoting [Re: HeyDan]
HeyDan Offline
Fresh Scripter

Registered: 2010-10-29
Posts: 14
Loc: Bangkok, Thailand
XP by the way
Top
#200543 - 2010-11-08 10:27 PM Re: quoting [Re: HeyDan]
HeyDan Offline
Fresh Scripter

Registered: 2010-10-29
Posts: 14
Loc: Bangkok, Thailand
For now I have written the KIX command line out to a batch file and then tell runnas to execute the batch file
Top
#200544 - 2010-11-09 11:36 AM Re: quoting [Re: HeyDan]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Try using the 8.3 file naming. See if that can help.
Top
#200551 - 2010-11-10 02:29 AM Re: quoting [Re: BradV]
HeyDan Offline
Fresh Scripter

Registered: 2010-10-29
Posts: 14
Loc: Bangkok, Thailand
Sorry, that's not possible in this situation. The problem is the spaces in the file name and I can't guarantee what the file will be called. Also, as these are auto-install scripts/exes/etc, we have used a naming scheme of:

 Code:
[number for ordering]_[hardware-specific-build-name or 'all']_[hostname or 'all']_[name which is up to the person creating the install file/script/whatever]


So, 8.3 is not at all possible and proclaiming spaces and odd characters to be illegal would be unfortunate as we are using the [name] part of the file name to display in the kixForms install window, so a human readable string is preferred.

For now, writing a temporary batch file to execute the command (and then immediately deleting it) is working, but is just a messy ?solution?.

Top
#200552 - 2010-11-10 02:38 AM Re: quoting [Re: HeyDan]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... you could always simply avoid spaces in the filespec.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#200553 - 2010-11-10 03:33 AM Re: quoting [Re: Les]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Am I completely missing the puzzle here? Under normal circumstances the easiest thing to do is "build" out your command line and then display it to the screen to make sure it looks like it supposed to....

 Code:
$cmd='runnas.exe /user:joe KIX32.EXE kixScript.kix $passedFile="C:\something or the other.txt"'
? $cmd
;shell $cmd 

Top
#200562 - 2010-11-10 10:55 AM Re: quoting [Re: Allen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I suspect that RUNNAS parses the command line parametes which it then passes on to the command, possibly with the quotes badly mangled.

Unfortunately CMD style command line parsing is probably the worst that I've come across, and trying to do things like escaping the quotes so that they make it through to the final task command line intact is an exercise in frustration.

Top
#200573 - 2010-11-11 04:23 AM Re: quoting [Re: Richard H.]
HeyDan Offline
Fresh Scripter

Registered: 2010-10-29
Posts: 14
Loc: Bangkok, Thailand
Yeah, cmd is not the most friendly shell I have come across ;\)

Allen: "C:\something or the other.txt" needs to be quoted as you have done, but runnas requires the whole command that it is to run to be quoted, as in (too lazy to change the internal single quotes to char() function calls):

 Code:
$cmd='runnas.exe /user:joe "KIX32.EXE kixScript.kix $passedFile='C:\something or the other.txt'"'


but cmd or/and runnas does not like single quote parameter quoting

Top
#200574 - 2010-11-11 04:40 AM Re: quoting [Re: HeyDan]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Did you see this in the /? for runnas?

 Quote:

Pass quotes inside a quoted string (using \" metachar):

> runnas /user:admin "\"c:\program files\my app\app.exe\"" /pass:xxx

Top
#200625 - 2010-11-16 04:40 AM Re: quoting [Re: Allen]
HeyDan Offline
Fresh Scripter

Registered: 2010-10-29
Posts: 14
Loc: Bangkok, Thailand
Hi ya Allen,

I think I did try that - It is the sort of thing I would try fairly early on. It seems to suggest that this might be the answer though, so maybe I mucked something else up when I tried that ... I will give it a go at some stage \:\)

Cheers,

H

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 640 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.063 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org