Hello all

I have a text file that basically contains one line that reads, as an example

adduser -u jsmith -n "xxxxxxxxx

now, what i'd like to do is to be able to make a directory name called jsmith, or whatever username that the text file will contain (as designated after the -u), and create a directory in that name. The username length will vary, but the -n will always appear after the username, and the -u will always appear before the username.

Thanks in advance everyone

Re: read text from txt file and create directory from that by Torgeir

Torgeir
Mon Feb 09 16:55:57 CST 2004

Andy wrote:

> I have a text file that basically contains one line that reads, as an example:
>
> adduser -u jsmith -n "xxxxxxxxx"
>
> now, what i'd like to do is to be able to make a directory name called jsmith, or whatever username that the text file will contain (as designated after the -u), and create a directory in that name. The username length will vary, but the -n will always appear after the username, and the -u will always appear before the username.

Hi

May ways to do this, here is one:


sTst = "adduser -u jsmith -n ddd"

aLine = Split(sTst)
For i = 0 To UBound(aLine)
If LCase(aLine(i)) = "-u" Then
sName = aLine(i + 1)
Exit For
End If
Next

WScript.Echo sName


' if you risk that there could be more than one space between
' -u and the user name, this will work better
sTst = "adduser -u jsmith -n ddd"

bSwitchIsFound = False ' init value
aLine = Split(sTst)
For i = 0 To UBound(aLine)

If bSwitchIsFound And aLine(i) <> "" Then
sName = aLine(i)
Exit For
ElseIf LCase(aLine(i)) = "-u" Then
bSwitchIsFound = True
End If
Next

WScript.Echo sName



--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Re: read text from txt file and create directory from that by anonymous

anonymous
Mon Feb 09 19:56:06 CST 2004

thanks for the response..
however i've run into a problem...
directly from the text file, the output is

adduser -u jsmith -n "joe smith

now, when i make it into a variable
i need to strip off the quotes around joe smith. what's the best way to do that
or can i just ignore the text after -n
the quotes are a stumbling block..

thanks
Andy

Re: read text from txt file and create directory from that by McKirahan

McKirahan
Mon Feb 09 20:26:21 CST 2004

"andy" <anonymous@discussions.microsoft.com> wrote in message
news:F071D852-876B-4260-B24E-AEBBAA1D339F@microsoft.com...
> thanks for the response...
> however i've run into a problem....
> directly from the text file, the output is:
>
> adduser -u jsmith -n "joe smith"
>
> now, when i make it into a variable,
> i need to strip off the quotes around joe smith. what's the best way to
do that?
> or can i just ignore the text after -n?
> the quotes are a stumbling block...
>
> thanks,
> Andy

strWithoutQuotes = Replace(strWithQuotes,Chr(34),"")



Re: read text from txt file and create directory from that by anonymous

anonymous
Tue Feb 10 13:11:05 CST 2004

thanks m, exactly what i needed....

A