Page 1 of 1 1
Topic Options
#94386 - 2002-10-15 03:21 PM DIR /N command in a script
Anonymous
Unregistered


The text below is part of a script I have written. I am haveing one small problem with it. The shell command line isn't working correctly. When the script runs, it doesn't like the /N switch in the DIR command. But if I go to a command prompt and type the same exact command, it works fine!! Can anyone help? Thanks!!

code:
 
$DIRLOC=E:\USERS


SHELL "COMMAND.COM /E:1024 /C DIR $DIRLOC /AD /B /N > $DIRLOC\HOMES.TXT"


Top
#94387 - 2002-10-15 03:26 PM Re: DIR /N command in a script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
for me it does not work. I'm not using win9x...

anyway, the reason why it does work for me is that /B says shortway and /N says longway.
the B-switch takes precedence before N.
_________________________
!

download KiXnet

Top
#94388 - 2002-10-15 03:34 PM Re: DIR /N command in a script
Anonymous
Unregistered


This is on a Windows NT 4 SP6a server. The /B is for Bare format and the /N is to display the long version of a long file name. One switch shouldn't over ride the other switch in this case. And like I said, it just doesn't work when put in to a Kixtart script.

/B Uses bare format (no heading information or summary).
/N New long list format where filenames are on the far right.

Top
#94389 - 2002-10-15 03:37 PM Re: DIR /N command in a script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mike, still the server does not matter.
why I said, I don't have win9x is that you are using command interpreter for win9x (command.com)

cmd.exe is the one for winNT and upwards.

still, I haven't got in any situation them both to work at the same line.
still, don't know about win9x.
_________________________
!

download KiXnet

Top
#94390 - 2002-10-15 04:06 PM Re: DIR /N command in a script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
This is from Windows XP..

quote:

C:\>dir /?
Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename]
Specifies drive, directory, and/or files to list.

/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files - Prefix meaning not
/B Uses bare format (no heading information or summary).
/C Display the thousand separator in file sizes. This is the
default. Use /-C to disable display of separator.
/D Same as wide but files are list sorted by column.
/L Uses lowercase.
/N New long list format where filenames are on the far right.

HTH,

Kent

[ 15. October 2002, 16:07: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#94391 - 2002-10-15 04:09 PM Re: DIR /N command in a script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kent, nice help you got there.
it still does matter what the help says.
it matters how it works.

can you use both of those?
_________________________
!

download KiXnet

Top
#94392 - 2002-10-15 04:10 PM Re: DIR /N command in a script
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
{Edit} Try %comspec% instead of stipulating 'cmd.exe' or 'command.com'. And, if you put the command into a var then you can more easily troubleshoot the command if necessary.{/Edit}
code:
$shellcmd="%comspec% /q /E:1024 /C DIR $DIRLOC /AD /B /N  > $DIRLOC\HOMES.TXT"
; ? $shellcmd
shell $shellcmd



[ 15. October 2002, 16:48: Message edited by: Waltz ]
_________________________
We all live in a Yellow Subroutine...

Top
#94393 - 2002-10-15 04:12 PM Re: DIR /N command in a script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hey boys,
we probably know already how shell works and what dir does.

the problem that N gets ignored does not get solved with syntax help and shelling test codes.
 
_________________________
!

download KiXnet

Top
#94394 - 2002-10-15 04:20 PM Re: DIR /N command in a script
Anonymous
Unregistered


I got it!! Thanks for everyones input. Lonkero was on the right track, with the COMMAND.COM and CMD.EXE. Here's the line that works!!

code:
 SHELL "CMD.EXE /E:1024 /C DIR $DIRLOC /AD /B /N  > $DIRLOC\HOMES.TXT"  


Top
#94395 - 2002-10-15 04:23 PM Re: DIR /N command in a script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
huh.
on what system you are using this as I still get the same listing. if /b is used, the /n gets ignored.
on both command.com and cmd.exe
_________________________
!

download KiXnet

Top
#94396 - 2002-10-15 04:39 PM Re: DIR /N command in a script
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
My only intent was to suggest the use of %comspec% to circumvent the cmd.exe vs command.com thingy...
_________________________
We all live in a Yellow Subroutine...

Top
#94397 - 2002-10-15 04:41 PM Re: DIR /N command in a script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
understood.

I actually have had problems with that too...
but, good point even though you didn't say it and I even missed your point...
 
_________________________
!

download KiXnet

Top
#94398 - 2002-10-15 04:47 PM Re: DIR /N command in a script
Anonymous
Unregistered


Ran it on a Windows NT 4 SP6 a computer. Processed over 225 directories with no problems.
Top
#94399 - 2002-10-15 04:50 PM Re: DIR /N command in a script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mike,
sure it "works" but is the output any different without the /N option?
I tried with N and without N when B was set and the output was just the same...
_________________________
!

download KiXnet

Top
#94400 - 2002-10-15 05:35 PM Re: DIR /N command in a script
Anonymous
Unregistered


When I ran it through Kixtart the original way using COMMAND.COM and without the /N switch, folder names over a certain number of characters were being truncated (ex. Usernam~1)
Top
#94401 - 2002-10-15 07:00 PM Re: DIR /N command in a script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also Not quite everything you wanted to know about RUN and SHELL
_________________________
There are two types of vessels, submarines and targets.

Top
#94402 - 2002-10-16 01:01 PM Re: DIR /N command in a script
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
Lonkero,
When I went to a dos prompt and pasted it from the list, It did not work. I got the /n error. But as soon as I realized that the $dirloc directory did not exist and changed it to an existing directory and removed the command.exe e:1024 /w which I did not need from a dos prompt it worked.
_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1110 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.065 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org