Author Topic: shell_exec dir  (Read 1032 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
shell_exec dir
« on: November 24, 2007, 10:21:27 am »
I'm trying to get a list of files inside a folder, and write that onto a file.. I have a major issue, and a few questions..
1) /n doesn't work, which is what I need most of all
2) Why are the filenames all in caps?
3) Why does it write to the file name, but all in caps?
4) Am I doing this right/properly?

Everything here works in the command line thing, but doesn't on the soldat server:
shell_exec('dir maps /w/a:-h-s-d/o:n/n > amaps.txt');
shell_exec('dir maps /n > amaps.txt');
Although this works:
shell_exec('dir maps /w/a:-h-s-d/o:n > amaps.txt'); (w/out t he /n)

I'm new to this type of thing fyi.

My home computer, Windows XP

Safe mode is off
« Last Edit: November 24, 2007, 10:28:11 am by DorkeyDear »

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: shell_exec dir
« Reply #1 on: November 24, 2007, 10:53:53 pm »
For compatability reasons, the server sends commands through command.com, which under XP emulates DOS as it is under 9X/ME. In this mode, files are all caps and in 8.3 format. The /N flag is not supported in compatability mode.

For reference:

Code: [Select]
DIR [drive:][path][filename] [/P] [/W] [/A[[:]attributes]]
  [/O[[:]sortorder]] [/S] [/B] [/L]

  [drive:][path][filename]
              Specifies drive, directory, and/or files to list.
  /P          Pauses after each screenful of information.
  /W          Uses wide list format.
  /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"
  /O          List by files in sorted order.
  sortorder    N  By name (alphabetic)       S  By size (smallest first)
               E  By extension (alphabetic)  D  By date & time (earliest first)
               G  Group directories first    -  Prefix to reverse order
  /S          Displays files in specified directory and all subdirectories.
  /B          Uses bare format (no heading information or summary).
  /L          Uses lowercase.

Switches may be preset in the DIRCMD environment variable.  Override
preset switches by prefixing any switch with - (hyphen)--for example, /-W.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: shell_exec dir
« Reply #2 on: November 25, 2007, 10:50:25 am »
So is there no way to get the full filename of the files listed?

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: shell_exec dir
« Reply #3 on: November 25, 2007, 11:50:25 am »
Not sure, maybe possible with a batch file, but no guarantees.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: shell_exec dir
« Reply #4 on: November 25, 2007, 01:45:38 pm »
Not sure, maybe possible with a batch file, but no guarantees.
I tried this, and the caps are gone, but /n still makes it not work :(

shell_exec('amaps.bat');

Quote from: amaps.bat
dir maps /w/a:-h-s-d/o:n/n > amaps.txt
doesn't work
Quote from: amaps.bat
dir maps /w/a:-h-s-d/o:n > amaps.txt
works

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: shell_exec dir
« Reply #5 on: November 25, 2007, 02:02:40 pm »
Because /n still isn't supported. What do you need /n for anyhow? If you want to get a list of maps without any extras, you can just use `dir /b maps\*.PMS` and you'll get a list like:

Code: [Select]
C:\Soldat>dir /b maps\*.PMS
Airpirates.PMS
Arena.PMS
Arena2.PMS
Arena3.PMS
...
Tropiccave.PMS

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: shell_exec dir
« Reply #6 on: November 25, 2007, 05:37:30 pm »
Because /n still isn't supported. What do you need /n for anyhow? If you want to get a list of maps without any extras, you can just use `dir /b maps\*.PMS` and you'll get a list like:

Code: [Select]
C:\Soldat>dir /b maps\*.PMS
Airpirates.PMS
Arena.PMS
Arena2.PMS
Arena3.PMS
...
Tropiccave.PMS
I'm new to this type of thing fyi
Didn't know about/see /b :P
Worked, but its still giving me the short names

I guess sense that darn capability mode, it can't be done.. Thx anyways.