Jump to content
  • Advertisement
Sign in to follow this  
mrmrcoleman

BATCH script problems...

This topic is 4021 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hoi! I am currently running a couple of batch scripts from my application. I would rather be using BASH but as far as I can tell there is no way to share a windows directory and then map it as a network drive from BASH. If I am wrong, PLEASE let me know!!! I am using 'net share' and 'net use' and as far as I can tell they do not report an error level on failure, but I need some way to figure out if they failed or not. Does anybody know how to do this in DOS Batch? I have considered grep'ing the output for certain strings but this seems like a fairly painstaking way to proceed. Any help with this would be greatly appreciated. Regards, Mark

Share this post


Link to post
Share on other sites
Advertisement
To catch the return code given by net.exe, try:


@echo off

net use
echo %ERRORLEVEL%



When I do "net use", it gives 0.
When I do "net use X: \\skjdfdshfdshfdsf\sdjfds", it gives 2 (I assume this means "error!").

Share this post


Link to post
Share on other sites
taby,

Thanks, my original test was flawed, you are right when you say that net does create an error level.

Fortunately in the meantime I found a way around this!

Regards,

Mark

Share this post


Link to post
Share on other sites
I strongly recommend Windows PowerShell if you need to do this sort of thing frequently. It's very powerful, and ties in to the .NET framework to give you a massive class library to work with. [smile]

Share this post


Link to post
Share on other sites
I've a question (hijack-alert)

What character is the wildcard from linux on the windows-console?

e.g. '> del *' -> "There's no such file, idiot!"

Share this post


Link to post
Share on other sites
Quote:
Original post by hydroo
What character is the wildcard from linux on the windows-console?
del * deletes all files in a directory. del * /q skips the prompt. As with most commands, del /? or help del displays further information.

(At least, del * deletes all the files under Vista). Some commands might require you to use *.* instead of *

Share this post


Link to post
Share on other sites
And is there no general wildcard? I mean is there no "sign" which tells the commandline to replace this with all matching files?

I want to do commands like "> myprogram *" and this should trigger the programm like "> myprogram file1 file2 file3 ..."

Share this post


Link to post
Share on other sites
... welcome to DOS :) It's nasty like that. For some bizarre reason, for example, you have to use this 'call' command to run one batch script from another, even though batch scripts are executable, and "normal" executables are fine... if you try to treat the other script like a .exe, then it will start, but Weird Things(TM) happen.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!