List Info

Thread: Re: relative path in windows XP




Re: relative path in windows XP
country flaguser name
United States
2008-03-28 01:43:59

> The problem is that you're using backslashes in a
> double-quoted string.
> Backslashes are escaping characters, so "."
> is really the same as ".".

keep in mind in perl, double quotes (") interpolate and single quotes do not

in other words if written as
system('....somefun.exe <input.txt');
your command would work

if you include a variable different things start to happen,
$input = 'input.txt';

system('....somefun.exe < $input'); # does not do what you want
system("....somefun.exe < $input&quot;); # does not do what you want for the original reason
system(";../../somefun.exe < $input&quot;); # does do what you want
system('....somefun.exe' < $input); # does do what you want
system('....somefun.exe' < "$input"); # does do what you want

you can also have a look at File::Spec, which handles os/filesystem path stuff transparently

use File::Spec;

$path = File::Spec->catfile( directories, $filename );

take this example:

print File::Spec->catfile( 'C:','WINDOWS','system32', 'nslookup.exe');
# on winxp prints C:WINDOWSsystem32nslookup.exe

system File::Spec->catfile( 'C:','WINDOWS','system32', 'nslookup.exe');

+Dave

--- On Thu, 3/27/08, Jeff Pinyan < japhy.734%40gmail.com">japhy.734gmail.com> wrote:

> From: Jeff Pinyan < japhy.734%40gmail.com">japhy.734gmail.com>
>; Subject: Re: [PBML] relative path in windows XP
> To: perl-beginner%40yahoogroups.com">perl-beginneryahoogroups.com
> Date: Thursday, March 27, 2008, 9:36 AM
> 2008/3/27 jiqiang yao < jiqiang123%40yahoo.com">jiqiang123yahoo.com>:
&gt; > I have a script:
> >
>; > #!perl -w
> > system(&quot;....somefun.exe
> <input.txt");
> >
>; > However, I got the warning message:
> >
>; > '..' is not recognized as an internal or
> external
> > command, operable program or batch file.
&gt; >
>; > Does anyone know what i should do to fix this relative
> > path problem?
>
> The problem is that you're using backslashes in a
> double-quoted string.
> Backslashes are escaping characters, so ".&quot;
> is really the same as ".&quot;. The
> nice thing is, you don't NEED to use backslashes, even
>; though you're on
> Windows. You can simply use forwardslashes, and the OS
> will know what to
> do:
>
> system "../../somefun.exe < input.txt&quot;;
&gt;
> --
> [Mary said,] "Do whatever he tells you." ~ John
>; 2:5
> The Cross Reference -
> http://thecrossreference.blogspot.com/
> Nos autem praedicamus Christum crucifixum (1 Cor 1:23)
&gt;
>
> [Non-text portions of this message have been removed]
>
>
> ------------------------------------
&gt;
> Unsubscribing info is here:
&gt; http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo!
> Groups Links
&gt;
>
>

__._,_.___
.

__,_._,___
Re: relative path in windows XP
country flaguser name
United States
2008-03-28 09:15:37

thanks!
excellent!

--- david wright < david_v_wright%40yahoo.com">david_v_wrightyahoo.com> wrote:

> > The problem is that you're using backslashes in a
> > double-quoted string.
> > Backslashes are escaping characters, so ".&quot;
> > is really the same as ".&quot;.
>
> keep in mind in perl, double quotes (") interpolate
> and single quotes do not
>
> in other words if written as
> system('....somefun.exe <input.txt');
&gt; your command would work
>
>
> if you include a variable different things start to
> happen,
> $input = 'input.txt';
>
> system('....somefun.exe < $input'); # does not do
> what you want
>; system(&quot;....somefun.exe < $input&quot;); # does not do
> what you want for the original reason
&gt; system(&quot;../../somefun.exe < $input&quot;); # does do what
>; you want
>; system('....somefun.exe' < $input); # does do what
>; you want
>; system('....somefun.exe' < "$input"); # does do
> what you want
>;
>
> you can also have a look at File::Spec, which
&gt; handles os/filesystem path stuff transparently
>
> use File::Spec;
>
> $path = File::Spec->catfile( directories, $filename
> );
>
> take this example:
>
> print File::Spec->catfile(
> 'C:','WINDOWS','system32', 'nslookup.exe');
> # on winxp prints C:WINDOWSsystem32nslookup.exe
>
> system File::Spec->catfile(
> 'C:','WINDOWS','system32', 'nslookup.exe');
&gt;
>
> +Dave
>
> --- On Thu, 3/27/08, Jeff Pinyan
&gt; < japhy.734%40gmail.com">japhy.734gmail.com> wrote:
&gt;
> > From: Jeff Pinyan < japhy.734%40gmail.com">japhy.734gmail.com>
>; > Subject: Re: [PBML] relative path in windows XP
> > To: perl-beginner%40yahoogroups.com">perl-beginneryahoogroups.com
> > Date: Thursday, March 27, 2008, 9:36 AM
> > 2008/3/27 jiqiang yao < jiqiang123%40yahoo.com">jiqiang123yahoo.com>:
&gt; > > I have a script:
> > >
>; > > #!perl -w
> > > system(&quot;....somefun.exe
> > <input.txt");
> > >
>; > > However, I got the warning message:
> > >
>; > > '..' is not recognized as an internal or
> > external
> > > command, operable program or batch file.
&gt; > >
>; > > Does anyone know what i should do to fix this
>; relative
> > > path problem?
> >
> > The problem is that you're using backslashes in a
> > double-quoted string.
> > Backslashes are escaping characters, so ".&quot;
> > is really the same as ".&quot;. The
> > nice thing is, you don't NEED to use backslashes,
> even
>; > though you're on
> > Windows. You can simply use forwardslashes, and
> the OS
> > will know what to
> > do:
> >
> > system "../../somefun.exe < input.txt&quot;;
&gt; >
> > --
> > [Mary said,] "Do whatever he tells you." ~ John
>; > 2:5
> > The Cross Reference -
> > http://thecrossreference.blogspot.com/
> > Nos autem praedicamus Christum crucifixum (1 Cor
> 1:23)
&gt; >
> >
> > [Non-text portions of this message have been
>; removed]
> >
> >
> > ------------------------------------
&gt; >
> > Unsubscribing info is here:
&gt; >
>;
http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo!
> > Groups Links
&gt; >
> >
> >
>

__________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )