![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | Script parameter problem Hi, there are two scripts test1.ps1: Quote: > $Args Quote: > $i = "'1234 5678' 22 33 zzz" > ./test1 $i Quote: > '1234 5678' 22 33 zzz test3.ps1: Quote: > ./test1 '1234 5678' 22 33 zzz Quote: > 1234 5678 > 22 > 33 > zzz variable. Or I'm totally blind? |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Script parameter problem I'm not quite sure what you mean but each space denotes a new argument (multiple spaces mean more arguments which get bundled into an array) so using the approach you used to assign to $i is correct for specifying a single argument ../test1 "'1234 5678' 22 33 zzz" n "Test" <olli.marx@xxxxxx> wrote in message news:%23xEdbDN%23IHA.4784@xxxxxx Quote: > Hi, > > there are two scripts > > test1.ps1: Quote: > > $Args > test2.ps1: Quote: > > $i = "'1234 5678' 22 33 zzz" > > ./test1 $i > Running test2 -> Output Quote: > > '1234 5678' 22 33 zzz > but it should be like > test3.ps1: Quote: > > ./test1 '1234 5678' 22 33 zzz > Running test3 -> Output: Quote: > > 1234 5678 > > 22 > > 33 > > zzz > How can I use a normal string - without converting it to an array - as a > variable. Or I'm totally blind? |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Script parameter problem Hi Neil, Quote: > I'm not quite sure what you mean but each space denotes a new argument > (multiple spaces mean more arguments which get bundled into an array) so > using the approach you used to assign to $i is correct for specifying a > single argument commandline ../test1 '1234 5678' 22 33 zzz and not ../test1 "'1234 5678' 22 33 zzz" Cheers, Oliver Quote: > "Test" <olli.marx@xxxxxx> wrote in message > news:%23xEdbDN%23IHA.4784@xxxxxx Quote: >> Hi, >> >> there are two scripts >> >> test1.ps1: Quote: >> > $Args >> test2.ps1: Quote: >> > $i = "'1234 5678' 22 33 zzz" >> > ./test1 $i >> Running test2 -> Output Quote: >> > '1234 5678' 22 33 zzz >> but it should be like >> test3.ps1: Quote: >> > ./test1 '1234 5678' 22 33 zzz >> Running test3 -> Output: Quote: >> > 1234 5678 >> > 22 >> > 33 >> > zzz >> How can I use a normal string - without converting it to an array - as >> a variable. Or I'm totally blind? |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Script parameter problem ahh - I think I see - you actually want unique parameters but you want to avoid using an array to build the input argument. Yes, I see now this is what you meant. I have absolutely no idea how to achieve that In order for $i toseparate the parameters it must (AFAIK) be an array OR you must convert $i into an array when you pass it through. Using a Split() wouldn't work for the example you've given but some regular expression jiggerypokery might do it. Sadly my regex skilz are not that great. soz n "Oliver" <olli.marx@xxxxxx> wrote in message news:uCfg5pQ%23IHA.5056@xxxxxx Quote: > Hi Neil, > Quote: >> I'm not quite sure what you mean but each space denotes a new argument >> (multiple spaces mean more arguments which get bundled into an array) so >> using the approach you used to assign to $i is correct for specifying a >> single argument > That's right. But I want 'expand' $i in that way, that $i becomes the > commandline > > ./test1 '1234 5678' 22 33 zzz > > and not > > ./test1 "'1234 5678' 22 33 zzz" > > Cheers, > Oliver > Quote: >> "Test" <olli.marx@xxxxxx> wrote in message >> news:%23xEdbDN%23IHA.4784@xxxxxx Quote: >>> Hi, >>> >>> there are two scripts >>> >>> test1.ps1: >>> > $Args >>> >>> test2.ps1: >>> > $i = "'1234 5678' 22 33 zzz" >>> > ./test1 $i >>> >>> Running test2 -> Output >>> > '1234 5678' 22 33 zzz >>> >>> but it should be like >>> test3.ps1: >>> > ./test1 '1234 5678' 22 33 zzz >>> >>> Running test3 -> Output: >>> > 1234 5678 >>> > 22 >>> > 33 >>> > zzz >>> >>> How can I use a normal string - without converting it to an array - as a >>> variable. Or I'm totally blind? |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Script parameter problem On Aug 7, 11:54*pm, Oliver <olli.m...@xxxxxx> wrote: Quote: > Hi Neil, > Quote: > > I'm not quite sure what you mean but each space denotes a new argument > > (multiple spaces mean more arguments which get bundled into an array) so > > using the approach you used to assign to $i is correct for specifying a > > single argument > That's right. But I want 'expand' $i in that way, that $i becomes the > commandline > > ./test1 '1234 5678' 22 33 zzz > > and not > > ./test1 "'1234 5678' 22 33 zzz" > > Cheers, > Oliver > > > Quote: > > "Test" <olli.m...@xxxxxx> wrote in message > >news:%23xEdbDN%23IHA.4784@xxxxxx Quote: > >> Hi, Quote: Quote: > >> there are two scripts Quote: Quote: > >> test1.ps1: > >> > $Args Quote: Quote: > >> test2.ps1: > >> > $i = "'1234 5678' 22 33 zzz" > >> > ./test1 $i Quote: Quote: > >> Running test2 -> Output > >> > '1234 5678' 22 33 zzz Quote: Quote: > >> but it should be like > >> test3.ps1: > >> > ./test1 '1234 5678' 22 33 zzz Quote: Quote: > >> Running test3 -> Output: > >> > 1234 5678 > >> > 22 > >> > 33 > >> > zzz Quote: Quote: > >> How can I use a normal string - without converting it to an array - as > >> a variable. Or I'm totally blind?- Hide quoted text - > - Show quoted text - Try: ps c:\> invoke-expression ".\test1.ps1 $i" Hope this helps, - Oisin PowerShell MVP http://www.nivot.org/ |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Script parameter problem Hi Neil, Quote: > ahh - I think I see - you actually want unique parameters but you want > to avoid using an array to build the input argument. Yes, I see now this > is what you meant. Quote: > I have absolutely no idea how to achieve that In order for $i to> separate the parameters it must (AFAIK) be an array OR you must convert > $i into an array when you pass it through. Using a Split() wouldn't work > for the example you've given but some regular expression jiggerypokery > might do it. Sadly my regex skilz are not that great. chars whit special meanings like " ' ` Cheers, Oliver Quote: > soz > n > > "Oliver" <olli.marx@xxxxxx> wrote in message > news:uCfg5pQ%23IHA.5056@xxxxxx Quote: >> Hi Neil, >> Quote: >>> I'm not quite sure what you mean but each space denotes a new >>> argument (multiple spaces mean more arguments which get bundled into >>> an array) so using the approach you used to assign to $i is correct >>> for specifying a single argument >> That's right. But I want 'expand' $i in that way, that $i becomes the >> commandline >> >> ./test1 '1234 5678' 22 33 zzz >> >> and not >> >> ./test1 "'1234 5678' 22 33 zzz" >> >> Cheers, >> Oliver >> Quote: >>> "Test" <olli.marx@xxxxxx> wrote in message >>> news:%23xEdbDN%23IHA.4784@xxxxxx >>>> Hi, >>>> >>>> there are two scripts >>>> >>>> test1.ps1: >>>> > $Args >>>> >>>> test2.ps1: >>>> > $i = "'1234 5678' 22 33 zzz" >>>> > ./test1 $i >>>> >>>> Running test2 -> Output >>>> > '1234 5678' 22 33 zzz >>>> >>>> but it should be like >>>> test3.ps1: >>>> > ./test1 '1234 5678' 22 33 zzz >>>> >>>> Running test3 -> Output: >>>> > 1234 5678 >>>> > 22 >>>> > 33 >>>> > zzz >>>> >>>> How can I use a normal string - without converting it to an array - >>>> as a variable. Or I'm totally blind? >>> |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: Script parameter problem Hi Oisin, Quote: > Hi, > > Try: > > ps c:\> invoke-expression ".\test1.ps1 $i" > > Hope this helps, Cheers, Oliver |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| using foreach-object as a parameter for another script | PowerShell | |||
| Script switch parameter as variable | PowerShell | |||
| CTP: Script cmdlet parameter attributes error | PowerShell | |||
| Passing a string array as a parameter from one script to another | PowerShell | |||
| Passing a HashTable object as a parameter to a script | PowerShell | |||