yodawoya has asked for the wisdom of the Perl Monks concerning the following question:

Sorry for such elementary and newbie question but I am new at this... so please please no bashing :-(

I need to execute dsmadmc from C:\Program Files\Tivoli\TSM\server\tsmdiag. When I try

@out=`C:\\Program Files\\Tivoli\\TSM\\server\\tsmdiag\\dsmadmc -id=$ID -pass=$PASS "checkin libvol i500 search=bulk checklabel=barcode status=$arg"`;

or

@out=`C:/Program Files/Tivoli/TSM/server/tsmdiag/dsmadmc -id=$ID -pass=$PASS "checkin libvol i500 search=bulk checklabel=barcode status=$arg"`;

I get an error that the external command cannot be recognized.

Any suggestion on how to fix this... Many Thanks in advance....he is the full script

#!/bin/perl $ID='drm'; $PASS='drm'; $VERBOSE=0; $RETRIES=10; $SLEEPTIME=120; sub check_in { my ($arg) = @_; @out=`C:\\Program Files\\Tivoli\\TSM\server\\tsmdiag\\dsmadmc -id=$ID +-pass=$PASS "checkin libvol i500 search=bulk checklabel=barcode statu +s=$arg"`; if ($VERBOSE) { print @out; } #look for idle status $match=1; $trycnt=1; #loop for x number of times if robot is busy or there is no req while ($trycnt<$RETRIES) { sleep 10; $out=`dsmadmc -id=$ID -pass=$PASS "q req"`; if ($VERBOSE) { print @out; } $trycnt++; if ($out=~m/ANR8373I /) { $trycnt=$RETRIES; } else { print "Robot busy - sleeping for $SLEEPTIME secs\n"; sleep $SLEEPTIME; } }

Replies are listed 'Best First'.
Re: How do I tell perl to excute a windows from a specif folder
by BrowserUk (Patriarch) on Mar 10, 2015 at 17:16 UTC

    You need to quote the program name because of the space in its path; Try:

    @out=`"C:\\Program Files\\Tivoli\\TSM\\server\\tsmdiag\\dsmadmc" -id=$ +ID -pass=$PASS "checkin libvol i500 search=bulk checklabel=barcode st +atus=$arg"`; #.....^...............................^........................^

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
Re: How do I tell perl to excute a windows from a specific folder
by toolic (Bishop) on Mar 10, 2015 at 17:15 UTC

    Tip #1 from the Basic debugging checklist: warnings

    Unrecognized escape \s passed through at line ...

    Maybe try \\TSM\\server

    Also, you first specify a full path to dsmadmc, then later you don't specify a path.

Re: How do I tell perl to excute a windows from a specif folder
by MidLifeXis (Monsignor) on Mar 10, 2015 at 17:17 UTC

    If I were to guess (and that is all it is b/c you didn't provide the error message verbatim), I would guess that it is trying to execute the C:/Program executable, as the shell is involved, and it breaks on spaces unless quoted. You will need to double quote (as you did the last set of parameters) the executable name.

    --MidLifeXis

Re: How do I tell perl to excute a windows from a specif folder
by dasgar (Priest) on Mar 10, 2015 at 18:14 UTC

    As a few others have pointed out, the issue appears to be that you need quotes due to a space in the file path.

    One suggestion that I would have for you is to store your external command in a variable and then test your script by having it print out the contents of that variable. That helps you verify that you have constructed your command correctly.

    When you do that, check to make sure that characters like '\' are being interpolated correctly by Perl. If that's not happening, then you didn't construct your string correctly. Also, you can manually type the printed out contents of the command variable to see if you can get it run. If both of those "tests" pass, then you can modify your code to actually run the command.

    In this case, I believe that if you opened a command prompt and ran 'cd c:\' and then tried running the command as you have it in your code, you would hit an error messages complaining about not finding 'C:\Program'. At that point, you probably would have realized that you needed to use quotes due to the space in the file path.

    Sometimes I get in a hurry and don't do this myself. When I do skip this step and something isn't going right, this is always the first thing I do to debug the issue. In other words, my first debug step is to verify that my script is really making the command call that I think that it is.

    Just thought I'd pass on this tip in case others might find it useful. It's helped me out numerous times.