Sign in to follow this  

BATCH script problems...

This topic is 3806 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
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'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

This topic is 3806 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this