Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Variables in system calls

by cybermack72 (Novice)
on Dec 13, 2001 at 02:32 UTC ( [id://131448]=perlquestion: print w/replies, xml ) Need Help??

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

I'm reading a serverlist into an array and per/server issuing commands. One of those commands is a mapping command, forwhich I'm trying to use:system ("net use j\:\\\\\$server\\c\$...etc. in my foreach statement I first print the $server to ensure it's reading the list (it is), but I get "Network error 53...when it tries to map the drive using the command above......this is a script run on Win32 mapping to Win32 machines.

Replies are listed 'Best First'.
Re: Variables in system calls
by kwoff (Friar) on Dec 13, 2001 at 02:38 UTC
    I'd put the string into a variable, then print that to see what the command actually being passed is. I assume you also tried it from the command-line without a perl script.
(tye)Re: Variables in system calls
by tye (Sage) on Dec 13, 2001 at 09:14 UTC

    You might consider:

    my $share= '//'.$server.'/c$'; $share =~ tr#/#\\#; system( "net use j: $share ..." );
    that way you don't have to count backslashes and don't need a backslash in front of the '$'.

            - tye (but my friends call me "Tye")
Re: Variables in system calls
by Fastolfe (Vicar) on Dec 13, 2001 at 03:24 UTC
    I think you have one-too-many back-slashes before $server. Do what the other poster suggested and print out the string you're using here.
Re: Variables in system calls
by strat (Canon) on Dec 13, 2001 at 16:10 UTC
    I always use the module Win32::NetResource; in combination with Win32::WinError it is rather easy to use.

    Best regards,
    perl -e "print a|r,p|d=>b|p=>chr 3**2 .7=>t and t"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://131448]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found