mkdir in perl

Discussion in 'Software' started by pallavimahajan, Aug 2, 2005.

  1. pallavimahajan

    pallavimahajan Private E-2

    Hi everyone,
    As im a newbie on Perl, please help me with my problem in MKDIR
    mkdir `$directory`, 0777;
    chdir $directory or die "can't chdir $directory: $!";


    I'm using the above the above lines to make a new directory (which is
    inputted by the user).


    Now I am not getting any error in making this directory, and i even see
    this directory in my files.
    However, if I manually try to access this directory from the prompt, I
    get the error
    nologin: pals: not found (if pals is the name of the directory)


    Please help me in this.
    Thanks
    Pal
     
  2. Coco

    Coco Sergeant Major

    You're using the wrong command. It's not chdir it's cd, that's why you're having trouble changing to the dir.
     
  3. theefool

    theefool Geekified

    You could be right....but:

    http://www.perl.com/doc/manual/html/pod/perlfunc/chdir.html

    This says otherwise....

    So, perhaps going to perl.com could help out with perl scripts.....

    In "DOS" CHDIR and CD is the same thing....
     
  4. QuickSilver

    QuickSilver Corporal

    chdir is a perl command for changing the directory that your program is pointing at.. meaning if you then go on to create a file without expressly specifying a path it will be created in that directory...

    If the Perl script has run successfully then it has sent a command to the OS to create that directory. You should be able to manually navigate to that directory on your own....

    Out of curiosity which OS are you using?
     
  5. Coco

    Coco Sergeant Major

    Perhaps I am wrong, it's been awhile since I've used perl. Although it seems weird to me since chdir isn't a valid linux command and almost all servers are running some sort of *nix environment.

    Although according to the documentation you posted you may very well be wanting to use the opendir command.
    http://www.perl.com/doc/manual/html/pod/perlfunc/opendir.html
     
  6. pallavimahajan

    pallavimahajan Private E-2

    I am on UNIX, writing my perl scripts.
    I have posted this question in various forums, but i havnt received any answer yet.

    I cud see my directory, but when i manually change to my directory on unix prompt, im unable to do so....
    Any suggestions?
    i have the mod changed as you have must have seen in the code, and the problem persists no matter which mod i give
    thanks
    pal
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds