Re: WOT: Scripting Question[Scanned]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Bradford wrote:
> Hi guys,
> 
> This is way off topic (hence WOT), but I am really stuck with this
> *windows* issue.
> 
> 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
> 
> 
> 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
> 
> I hoping one of you guys can help me! Any pointers would be greatly
> appreciated!
> 
> I know it's off topic, but bear with me, I've all ready replaced a load
> of our machines with FC5 so I've earnt some brownie points! Even if you
> can point me in the right direction.
> 
> Thanks for reading,
> 
> -Chris
> 
If the text is formatted as you have shown above, you may want to
use cut on it to get the number field before disk. You would use the
-b or --bytes= option to only get the fields you are after. The
advantage here is that you do not care if there are spaces in other
fields that come before the one you are after. The disadvantage is
that it only works with fixed columns. You can then feed the output
of cut into your for loop.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux