Hi,
I have one problem in perl script development.

I have big logic executing in script and finally should save in directory structure specified.

directory structure is created at runtime dependind on user runtime arguments by argv

my MAKEPATH.the script works if i gave destination directory as

/home/abhinav/direc1/ (/home/abhinav/) is my root directory.

But if i give /proj/xy/debug/ means directory not creating and giving errors like

perrmission denied.Bur i PWD means it is cmng like /home/abhinav/

so i was in my directory only bur not creating.

That was error please try to help me

hi,

Actually /proj/xy it was not there.Depending on user argv at runtime

i was creating by using makepath.

This was the code i was trying

if (! -d $dp1)
{
 mkpath($dp1) or die "Failed to create $dp1: $!\n";
}

Where $dp1=/proj/xy/z/

Edited 6 Years Ago by koduruabhinav: n/a

this was the error
mkdir /proj/xy: No such file or directory at tmp.pl line 47

but i was not getting this erroe if i gave directory as

/home/abhinav/proj/xy/z/ where /home/abhinav/ is my root directory

which one you are using?

1. mkdir
or
2. mkpath

mkdir : Creates directory for first level only.
mkpath : Creates directory for Nth level
if you are using mkpath you must declare the 'File:: Path' module.

For your example you tried create more than one level. So must use mkpath and aware of the permission.

Edited 6 Years Ago by k_manimuthu: n/a

I assume you want to create directory in your destination path.
If you use the mkpath function, You must provide the fullpath.
You concat destination directory with your runtime directory.

Try the below code in your file

use File::Path;

### Declare your destination directory
$dest=”/home/abhinav/direc1”;

### get the runtime directory
$dp1=”/proj/xy/z/”;

if (! -d “$dest/$dp1”)
{
 mkpath(“$dest/$dp1” or die "Failed to create $dest/$dp1: $!\n";
}

Edited 6 Years Ago by k_manimuthu: n/a

What user are you doing this as? If you're trying to create a directory in the root directory you need to be root, otherwise it won't work as the permissions for the root directory are normally drwxr-xr-x

Shouldn't the mkdir be "./proj/xy" or "proj/xy" if you wish to create within your home directory? "/proj/xy" would seem to try to create the directory from the root.

This question has already been answered. Start a new discussion instead.