Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6331655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:06:41+00:00 2026-05-24T18:06:41+00:00

My function is having problems creating and copying the contents to the new directory

  • 0

My function is having problems creating and copying the contents to the new directory (also I’m not sure if this is the best way to do this, so alternate suggestions are welcome).

I have 2 network drives mounted via /etc/fstab like this:

//128.251.108.xxx/Data/Agilent_Data /home/lv_admin/uslonsnas001 cifs cred=/etc/.na02passwd,rw,umask=0000,uid=www-data,gid=webgroup 0 0
//128.251.108.xx/c$/Agilent /home/lv_admin/uslonsapp003 cifs cred=/etc/.na02passwd,rw,umask=0000,uid=www-data,gid=webgroup 0 0

Basically, when prompted with a file path from uslonsapp003 mount I check to see if the directory structure exists in uslonsnas001 and create the recursive directory if not. Then I copy the content from uslonsapp003 to the new structure location in uslonsnas001. Here is my code:

$pImagePath = "http://uslonsapp003:8080/boardtests/2011/4/29/12/30/8051/Images/E_1-c274.jpg";
//strip off the path name up to '2011' and take off the image name at the end
    $startpos = strpos( $pImagePath, "/boardtests/" ) + strlen( "/boardtests/" );
    $endpos   = strpos( $pImagePath, "/Images/" );
    $file_dir = substr( $pImagePath, $startpos, ( $endpos - $startpos ) );
    $orig_dir = "/home/lv_admin/uslonsapp003/ITFSS/DataStore/BoardTest/" . $file_dir;
    $new_dir  = "/home/lv_admin/uslonsnas001/BoardTest/" . $file_dir;
    if( !is_dir( $new_dir ) )
        if( !shell_exec("mkdir -p $new_dir") )    return array( "status" => 0, "errordesc" => "failed to make dir: '" . $new_dir . "'" );
    if( !shell_exec("cp -r $orig_dir $new_dir") ) return array( "status" => 0, "errordesc" => "failed to copy from: '" . $orig_dir . "' to: '" . $new_dir . "'" );
    return array( "status" => 1 );

I’ve been getting both errors, ‘failed to make dir…’ and ‘failed to copy from…’

This is executed through Apache, I’m assuming it’s a permissions problem but thats just my ‘hunch’. Please help!

I’ve tried adding sudo to the beginning of the shell_exec()’s but that still doesn’t work.

UPATED1

I figured out that the mkdir was failing because when I created the /home/lv_admin/uslonsnas001 directory I didn’t change the mod, owner, and group on it to the one that would be using it (www-data). Doing the following fixed that part:

$ sudo chmod 775 ~/uslonsnas001
$ sudo chown www-data ~/uslonsnas001
$ sudo chgrp webgroup ~/uslonsnas001

But I’m still having problems with the copy command, now saying “Module ‘ODBC’ already Loaded”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:06:41+00:00Added an answer on May 24, 2026 at 6:06 pm

    Unfortunately the problem was simple. My original mount point was not setup with write permissions for root. After changing the mount point owner and group to root it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're having a significant number of problems creating a bulk upload function for our
I am new to OOP having this code and am having a problem creating
im having problems creating a function that must return the amount of goals of
I seem to be having some problems creating a jquery plugin. I am testing
I am having some problems creating a query that gives me the average of
I'm having problems creating custom forms in pyramid_formalchemy. I suspect there is a bug
Hi all I am not sure how to approach this problem. I have a
Having a few problems with Timers within a service on Win2k3... Basically, creating a
I am having problems creating a managed class with namespace in C++/CLI. I would
Im creating a new library for a company. The structure I follow is (function()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.