Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Windows 7 Forum Vista Tutorials Tags

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 Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Re: Command substitution

Reply
 
LinkBack Thread Tools Display Modes
Old 01-08-2009   #1 (permalink)
Brandon Shell [MVP]
Guest


 
 

Re: Command substitution

Ah... I did misunderstand your statement. What you want should be even easier

myscript.py (ls * | %{$_.fullname})

Brandon Shell [MVP]
------------------------
Blog: http://www.bsonposh.com/
Author: http://www.TurboChargeAD.org
Profile: https://mvp.support.microsoft.com/profile/Brandon

K> Thank for the link, which is interesting reading, however I don't
K> think it solves my problem. I get an error when I try to follow your
K> example:
K>
Quote:
Quote:

>> set f=ls *
>> myscript.py "\\%f%"
K> Traceback (most recent call last):
K> File "myscript.py", line 74, in <module>
K> lines = open(fname, "r").readlines()
K> IOError: [Errno 2] No such file or directory: '\\\\ls *'
K> So, you see that the literal string "ls *" is passed as an argument,
K> not the expanded list of files. Yes, the script is in python, so I
K> will probably jsut modify it to accept globs. I was hoping, however,
K> that Windows will allow me to somehow substitute the command and do a
K> fancy one-liner.
K>
K> Cheers,
K> Karol
K> On Jan 8, 3:33 pm, Brandon Shell [MVP] <a_bshell.m...@xxxxxx>
K> wrote:
K>
Quote:
Quote:

>> I have a blog post that shows an example of what your looking for "I
>> think."
>>
>> http://bsonposh.com/archives/236
>>
>> K> Hi,
>> K>
>> K> I'm wondering how can I substitute the outcome of one command in
>> K> another without using for? That is, I want to evaluate one command
>> K> and pass the outcome as an argument to some other command, or
>> script.
>> K>
>> K> Under bash (in linux) this would be simply, for example:
>> K>
>> K> ./myscript `ls *.cpp`
>> K>
>> K> I cannot find any information on how to do this in an equally
>> simple
>> K> fashion.
>> K>
>> K> Thanks for any help,
>> K> Karol


My System SpecsSystem Spec
Reply

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Solved Make a command prompt run a command as soon as it opens? Fmjc001 General Discussion 11 11-17-2008 12:37 PM
How to perform variable substitution in powershell? Arun Kumar PowerShell 0 10-30-2008 07:56 AM
Command Line Ren (Rename) command broken? SixSigmaGuy Vista General 5 05-20-2008 05:52 AM
Command & variable substitution Chris PowerShell 5 01-09-2008 07:45 AM
Stumped by variable substitution K Kong PowerShell 8 05-16-2007 03:03 AM


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53