Bat file return value ?

Discussion in 'AutoCAD' started by petervose, Nov 3, 2004.

  1. petervose

    petervose Guest

    Hi, I'm running a batch file from lisp to map a drive to a server (net use N: \\server\share). This works fine, but I cannot be sure whether or not it has actually worked and all's OK to continue with my lisp as I'm unsure where or how the results of this batch file command are stored. I could of course search for a file I've previously planted there but that seems messy. Could anyone let me know how to establish the success or failure of this command ?
    Thanks
    Peter
     
    petervose, Nov 3, 2004
    #1
  2. petervose

    T.Willey Guest

    If you are just trying to see if the drive gets mapped, could you do something like this?

    (findfile "N:\\.")

    Tim
     
    T.Willey, Nov 3, 2004
    #2
  3. petervose

    petervose Guest

    Thanks Tim,
    The N: drive is being constantly remapped to different servers as I am running a routine that's checking for the appearance of new files on many servers. the bat file actually attempts to remove the current mapping before applying the new one, and this is where I seem to have problems as, if the drive wont disconnect (net use N: /delete /y), the new server won't remap to the new server, and the trouble starts.
    Using (findfile "N:\\") will therefore always return a positive result.
    Since posting this I've found I can create an environment variable by using "set myvar=net use n: \\server\share" but I'm still unsure how to get the value of 'myvar' back into the lisp environment.
    Cheers
    peter
     
    petervose, Nov 3, 2004
    #3
  4. petervose

    Tom Smith Guest

    getenv function?
     
    Tom Smith, Nov 3, 2004
    #4
  5. petervose

    petervose Guest

    (getenv myvar) seems to always retun nil. I've used "set myvar=net use n:\\server\share", and then (in a cmd shell) typed %myvar% and it returns the string "The command completed successfully" which is great, but I don't know how to get this value back into my lisp routine.
    Thanks Peter
     
    petervose, Nov 3, 2004
    #5
  6. petervose

    Tom Smith Guest

    Interesting. I haven't had occasion to do anything like this, but would have
    thought setenv and getenv would work. I can use those within an Acad session
    to set and retrieve values.

    I'm a little rusty on DOS, but if I type "set testvar=foo" in a cmd shell,
    then type "echo %testvar%" it returns "foo." If I type "set testvar" it
    returns "testvar=foo." I believe the %variable% syntax only applies in
    certain contexts, such as in batch files.
     
    Tom Smith, Nov 3, 2004
    #6
  7. petervose

    ECCAD Guest

    Try:
    (getvar "myvar")
    Note, your var is a string.
    Bob
     
    ECCAD, Nov 3, 2004
    #7
  8. petervose

    petervose Guest

    It seems that using 'set' in a batch file doesn't actually create an 'environment variable', (doesn't appear in user or system variable list) and therefore cannot be recalled using (getenv myvar) but it does create some type of variable as it can be recalled by surrounding the variable name with percentage symbols in a shell window. I'm still confused but Thanks for all the input..
    Peter
     
    petervose, Nov 4, 2004
    #8
  9. petervose

    ECCAD Guest

    I think you are incorrect.
    In autoexec.bat - place
    SET TEMP=C:\WINDOWS\TEMP
    (restart machine so it executes autoexec.bat)
    In Autocad:
    Command: (getenv "temp")
    "C:\\WINDOWS\\TEMP"

    Bob
     
    ECCAD, Nov 4, 2004
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.