WOT: Scripting Question[Scanned]

Chris Bradford chrisbradford at cambridge-news.co.uk
Thu Jul 27 18:40:35 UTC 2006


Alexander Dalloz wrote:
> Chris Bradford schrieb:
>
>> Unfortunately in my environment I still have a few windows (yes i 
>> know!) servers, and on one of them I am trying to make a script that 
>> will interpret a text file called 'disc.txt' that looks like this:
>>
>>                   jo tynan                 15  Disc    
>> wdica                                 KIML                      1  
>> Disc    wdica                                 
>> sararyan                  6  Disc    rdpwd              *There ARE 
>> spaces at the beginning of each line for some reason.*
>>
>> The file is generated every hour by the command:
>>
>> qwinsta /SERVER:servername | find "Disc" > disc.txt
>
> I wouldn't have expected "find" in this command. Wouldn't that be "grep"?
>
>> Is there a way that I can pick out just the number, which is a 
>> session number, on each line and remove the text? Maybe remove all 
>> other characters? Or just pick out them number on each line for use 
>> in a later command.
>>
>> Then, I would like a command to be run for every number in the text 
>> file, I assume something like this would work:
>>
>> for "i" in textfilename run a_script_name
>>
>> The command that needs to be run for each session number is:
>>
>> rwinsta /SERVER:servername number_from_above_file
>
> > -Chris
>
> while read line
>    do rwinsta /SERVER:servername $(echo $line | awk '{print $3}')
> done < disc.txt
>
> Not sure you want to have the "disc.txt" file any pupose. If not you 
> could do both steps (qwinsta and rwinsta) in one step.
>
> Alexander
>
>
 > Alexander,

Firstly thanks for your reply,

I do not need to have the disc.txt file, how would I remove this step?

I thought this was necessary..

Many thanks,

-Chris


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com




More information about the users mailing list