Returning DIR command into Variable without writing to disk??

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

Returning DIR command into Variable without writing to disk??

Post by MigrationUser »

08 Jul 2008 15:59
dynamis_dk


Hi all,

First post so take it easy on me :)

I've got a little issue am sure someone can help with.

I need to get the output from:

"DIR *.GHO /B" into a variable for use something like:

GHOST.EXE [OPTIONS ETC] SOURCE=FILENAME_VAR

Thing is i need to do this without writing to disk as its to run from a Plain DOS bootable DVD.

I already can do this using SET /P <filename.txt method but i can't do it without writing the DIR output like this: dir *.gho /B>filename.txt

Any ideas??

----------------------------

#2 09 Jul 2008 15:08
bluesxman


Have you looked at the "FOR /F" command?

Last edited by bluesxman (09 Jul 2008 15:12)

cmd | *sh | ruby | chef

----------------------------

#3 09 Jul 2008 15:16
dynamis_dk


No I hadn't lol... My batch scripting is basic at best but having a quick google around i have this:

Code: Select all

ECHO off
FOR /F %%G IN ('DIR *.GHO /B') DO SET GHOSTFILE=%%G
ECHO ghost.exe -fx -sure -clone,mode=load,src=R:\%GHOSTFILE%,dst=1,szeL
Works a treat!!

Thanks for the direction

----------------------------

#4 09 Jul 2008 15:57
dynamis_dk


Bum!!

Thought i had it sorted!! BUT...

the FOR /F command won't work with the Dr DOS cd i've using as its booting from a CD into a pure dos enviroment.

any suggestions??

----------------------------

#5 09 Jul 2008 16:41
bluesxman


Yeah "FOR /F" was introduced in the WinNT era as were lots of other useful commands "SET /P" included (I'm surprised that command is even available). You might be SOOL there, I haven't touched "Real" DOS in donkey's years, and I've not messed with Dr DOS at all, so can't say with authority ... I'm struggling to think of a way around this -- old school batch scripting under DOS is a somewhat limited affair, there are many things you'd like to do that you simply cannot.

Maybe there's some third party tool you could use, but what it is I cannot say.

Afterthought: Is the ".GHO" file going to be on the bootable CD? If so, why can't you hard code the name into the script?

cmd | *sh | ruby | chef

----------------------------

#6 10 Jul 2008 09:07
dynamis_dk


In the past i've had the autoexec in a bootdisk.img file point to a batchfile on the cdrom along with the ghost file. then it was just a case of updating the batch file before burning to the dvd with the correct path. Issue is more often than not people screw up the batchfile when editing it so i wanted to hide all the bits in the bootdisk.img file so its makes it as simple as possible. The .GHO file name will change from CD to CD so it needs changing each time we create a new CD

I can aways program something myself and compile it i was just hoping that it may be possible with commands already available.

Are the commands (like FOR /F) available if you create a MSDOS bootdisk using a WinXP machine?? I must admit, the ghost bootable images i created ages back we're from a real dos bootdisk i hacked to bit to suit my need, a colleague just pointed out it maybe worth trying to do it with a winXP made bootdisk.

----------------------------

#7 10 Jul 2008 10:44
bluesxman


I don't know for a fact, best I could offer is to suggest that you give it a go!

cmd | *sh | ruby | chef

----------------------------

#8 10 Jul 2008 16:11
dynamis_dk


damn...

doesn't work :(

Looks like i might be making a little program to do it instead..

cheers for the assistance tho

----------------------------

#9 13 Jul 2008 11:40
bspus


For /F is winNT only? Are the other forms of For available in MS-DOS or is all of For unavailable?

I was looking at a MS-DOS 6 reference page and it listed For as a command, though it did not specify available switches.

Also, command.com (the old shell that is included in win9x) is also available in NT/XP, along with cmd.exe. It too knows For /F.

If MS-DOS 6 does indeed have a For /F it might just be a limitation of DR-DOS. It's a longshot, but if you found that command.com from MS-DOS and used it instead of the DR-DOS equivalent, could it perhaps work? Otherwise, I suppose you have no choice but to implement the functionality yourself

----------------------------

#10 14 Jul 2008 01:48
bluesxman


To the best of my recollection, the "FOR" command (in its most basic form) was available long before MS-DOS 6.x; the "/F" option (and others) weren't available till the WinNT4 era.

cmd | *sh | ruby | chef
Post Reply