<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl: Current Directory in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666505#M102641</link>
    <description>There is no discrepancy in this, its working properly, Check out here, &lt;A href="http://perl.active-venture.com/lib/Cwd.html" target="_blank"&gt;http://perl.active-venture.com/lib/Cwd.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
    <pubDate>Tue, 08 Nov 2005 03:09:43 GMT</pubDate>
    <dc:creator>Arunvijai_4</dc:creator>
    <dc:date>2005-11-08T03:09:43Z</dc:date>
    <item>
      <title>Perl: Current Directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666502#M102638</link>
      <description>Hi!&lt;BR /&gt;I was using a piece of code to find out the curent dir of the script:&lt;BR /&gt;&lt;BR /&gt;use Cwd;&lt;BR /&gt;my $dir = getcwd; #current directory&lt;BR /&gt;&lt;BR /&gt;I found something special: When the script , let's say in /tmp/scripts has been run by another script in /tmp, then $dir contains the current directory of the "main" script (/tmp), and not the one I need (/tmp/scripts). &lt;BR /&gt;&lt;BR /&gt;Does anybody know another function that works properly?</description>
      <pubDate>Tue, 08 Nov 2005 02:57:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666502#M102638</guid>
      <dc:creator>Kalin Evtimov</dc:creator>
      <dc:date>2005-11-08T02:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Perl: Current Directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666503#M102639</link>
      <description>You are not chaning any directory right? If you are moving physically from one directory to another directory with cd then PWD variable will be changed. Cwd is updated on that. Else, executiong patch will be same so that it will show /tmp only.&lt;BR /&gt;&lt;BR /&gt;In child script change directory with cd then print getcwd information. It will show /tmp/scripts locations.&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Tue, 08 Nov 2005 03:03:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666503#M102639</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-08T03:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Perl: Current Directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666504#M102640</link>
      <description>This is the proper functionality indeed. If you invoke it from a script running under /tmp the actual current working directory will definitely be /tmp. cwd means the working directory not where the directory that the script resides.&lt;BR /&gt;&lt;BR /&gt;You can also see this behaviour if you go in a different directory and invoke the script using   the full path&lt;BR /&gt;&lt;BR /&gt;ie.&lt;BR /&gt;&lt;BR /&gt;#cd /&lt;BR /&gt;#/tmp/scripts/myscript&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;then cwd will be / not /tmp/scripts&lt;BR /&gt;&lt;BR /&gt;hth</description>
      <pubDate>Tue, 08 Nov 2005 03:06:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666504#M102640</guid>
      <dc:creator>Orhan Biyiklioglu</dc:creator>
      <dc:date>2005-11-08T03:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Perl: Current Directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666505#M102641</link>
      <description>There is no discrepancy in this, its working properly, Check out here, &lt;A href="http://perl.active-venture.com/lib/Cwd.html" target="_blank"&gt;http://perl.active-venture.com/lib/Cwd.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Tue, 08 Nov 2005 03:09:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666505#M102641</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2005-11-08T03:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Perl: Current Directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666506#M102642</link>
      <description>Yeah, I know ot is working properly, but I need the directory where the child script is. When the whole thing is run by cron, then it looks even worse, because my $dir is / :(&lt;BR /&gt;Imagine, I want to put the whole stuff on another server and the main script is not in /tmp, but in /usr. This is why I cannot use absolute names. I need for each script to find out where it resides and put that in $dir</description>
      <pubDate>Tue, 08 Nov 2005 03:43:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666506#M102642</guid>
      <dc:creator>Kalin Evtimov</dc:creator>
      <dc:date>2005-11-08T03:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Perl: Current Directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666507#M102643</link>
      <description>Have you tried with use FindBin; ?? &lt;BR /&gt;&lt;BR /&gt;use FindBin;&lt;BR /&gt;&lt;BR /&gt;to find the directory where the perl script resides.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://perl.org.il/pipermail/perl/2003-January/000948.html" target="_blank"&gt;http://perl.org.il/pipermail/perl/2003-January/000948.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Tue, 08 Nov 2005 03:55:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666507#M102643</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2005-11-08T03:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Perl: Current Directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666508#M102644</link>
      <description>1. use Cwd; is NOT driven by the $PWD environment variable. The reason is clear: there might not be one. Not all parent shells define it (think csh)&lt;BR /&gt;&lt;BR /&gt;2. check the scripts for chdir () calls. The script, whoever/whatever called it, can be in one single location at the time, so if a parent script (sh, perl, C, ...) does a cd/chdir, the child script shares that location&lt;BR /&gt;&lt;BR /&gt;3. If you need to know the location of the running script, you can indeed use FindBin, but you can also examine $0 and/or $^X&lt;BR /&gt;&lt;BR /&gt;Demo:&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 110 &amp;gt; cat test.sh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;pwd&lt;BR /&gt;&lt;BR /&gt;echo none&lt;BR /&gt;perl -l test.pl&lt;BR /&gt;&lt;BR /&gt;echo relative&lt;BR /&gt;perl -l ./test.pl&lt;BR /&gt;&lt;BR /&gt;echo absolute&lt;BR /&gt;perl -l /tmp/test.pl&lt;BR /&gt;&lt;BR /&gt;echo chdir&lt;BR /&gt;cd /usr&lt;BR /&gt;pwd&lt;BR /&gt;&lt;BR /&gt;echo none&lt;BR /&gt;test.pl&lt;BR /&gt;&lt;BR /&gt;echo relative&lt;BR /&gt;../tmp/test.pl&lt;BR /&gt;&lt;BR /&gt;echo absolute&lt;BR /&gt;/tmp/test.pl&lt;BR /&gt;&lt;BR /&gt;echo extend PATH&lt;BR /&gt;export PATH=$PATH":/tmp"&lt;BR /&gt;&lt;BR /&gt;echo none&lt;BR /&gt;test.pl&lt;BR /&gt;&lt;BR /&gt;echo relative&lt;BR /&gt;../tmp/test.pl&lt;BR /&gt;&lt;BR /&gt;echo absolute&lt;BR /&gt;/tmp/test.pl&lt;BR /&gt;lt09:/tmp 111 &amp;gt; cat test.pl&lt;BR /&gt;#!/pro/bin/perl&lt;BR /&gt;&lt;BR /&gt;use warnings;&lt;BR /&gt;use strict;&lt;BR /&gt;&lt;BR /&gt;use Cwd;&lt;BR /&gt;&lt;BR /&gt;my $pwd = getcwd;&lt;BR /&gt;print "\$0: $0, \$^X: $^X, pwd: $pwd\n";&lt;BR /&gt;lt09:/tmp 112 &amp;gt; sh test.sh&lt;BR /&gt;/tmp&lt;BR /&gt;none&lt;BR /&gt;$0: test.pl, $^X: /pro/bin/perl, pwd: /tmp&lt;BR /&gt;&lt;BR /&gt;relative&lt;BR /&gt;$0: ./test.pl, $^X: /pro/bin/perl, pwd: /tmp&lt;BR /&gt;&lt;BR /&gt;absolute&lt;BR /&gt;$0: /tmp/test.pl, $^X: /pro/bin/perl, pwd: /tmp&lt;BR /&gt;&lt;BR /&gt;chdir&lt;BR /&gt;/usr&lt;BR /&gt;none&lt;BR /&gt;test.sh: line 19: test.pl: command not found&lt;BR /&gt;relative&lt;BR /&gt;$0: ../tmp/test.pl, $^X: /pro/bin/perl, pwd: /usr&lt;BR /&gt;absolute&lt;BR /&gt;$0: /tmp/test.pl, $^X: /pro/bin/perl, pwd: /usr&lt;BR /&gt;extend PATH&lt;BR /&gt;none&lt;BR /&gt;$0: /tmp/test.pl, $^X: /pro/bin/perl, pwd: /usr&lt;BR /&gt;relative&lt;BR /&gt;$0: ../tmp/test.pl, $^X: /pro/bin/perl, pwd: /usr&lt;BR /&gt;absolute&lt;BR /&gt;$0: /tmp/test.pl, $^X: /pro/bin/perl, pwd: /usr&lt;BR /&gt;lt09:/tmp 113 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Tue, 08 Nov 2005 05:25:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-current-directory/m-p/3666508#M102644</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-11-08T05:25:16Z</dc:date>
    </item>
  </channel>
</rss>

