Page 1 of 1
DOS shell command substitution?
Posted: Fri Feb 02, 2007 2:53 am
by Solar
I know this is a long shot, but is there any way to do something similar to Unix backticks / $() under MS-DOS?
Please don't laugh, but I'd need something like that for work. I'd really hate to do this with temporary files.
Posted: Fri Feb 02, 2007 4:36 am
by Solar
Forget it... after much googling, I came to realize the full extend of incompetence that is MS-DOS... you can't do command substitution, you can't even read in a temporary file into a variable without major stunts, and then only if the temporary file is one line only (which must be less than 127 characters)... oi, crickey...
Posted: Fri Feb 02, 2007 6:00 am
by Candy
Solar wrote:Forget it... after much googling, I came to realize the full extend of incompetence that is MS-DOS... you can't do command substitution, you can't even read in a temporary file into a variable without major stunts, and then only if the temporary file is one line only (which must be less than 127 characters)... oi, crickey...
You can't even use proper pipelines.
You could of course try using djgpp to compile bash, using some dos-windows subform of bash or using / porting another shell that does support it. Backticks would be a good idea for it, since that at least doesn't require having multiple commands running at the same time. Did you try their && logic already? Iirc it came down to "if the first command fails the second doesn't run, so it doesn't fail, so it succeeds, so the third command is run as long as the second command succeeds or the first fails" which wasn't really what I had intended with &&.
Posted: Fri Feb 02, 2007 6:03 am
by Solar
Candy wrote:You could of course try using djgpp to compile bash...
No go. It's native tools or nothing (production environment constraints), which also rules out Perl script. And I won't start writing a C prog for this stuff... well, the script will look ugly and be much less elegant than I prefer my code to be, but it's unlikely anyone else will use it anyway...