Unable to copy image from remote server to another server

Hello Experts.

I am in dire need of your help.

the following asp code used to copy files from one remote server to another.

First, it used to work with just regular copy. That stopped working.

I changed it to xcopy. It worked for awhile but for some reason that I don't understand, it stopped copying the image.

If you response.write it, it shows the name of the image that it is trying to copy. So, it can see it but it just can't copy it.

Can someone please help???

Here is the code:
sql_copy = "exec master.dbo.xp_cmdshell 'xcopy z:\HW6\AllPhotos\thumbnails\" & str2 & " c:\inetpub\wwwroot\ImageFile\'"
 
Many thanks in advance.

Open in new window

LVL 29
sammySeltzerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vs1784Commented:
What happens if you run that query in Query editor window?

Is it SQL 2000 or 2005?

In SQL 2005 xp_cmdshell is default off, you need to enable it from Surface area configuration or by using below code


USE master 
GO 
EXEC sp_configure 'show advanced options', 1 
GO 
RECONFIGURE WITH OVERRIDE 
GO 
EXEC sp_configure 'xp_cmdshell', 1 
GO 
RECONFIGURE WITH OVERRIDE 
GO 
EXEC sp_configure 'show advanced options', 0 
GO

Open in new window

0
sammySeltzerAuthor Commented:
Thanks vs1784 for your prompt response.

I ran it and got the following:

DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.
Server: Msg 15123, Level 16, State 1, Procedure sp_configure, Line 78
The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
 
Valid configuration options are:

DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Configuration option 'show advanced options' changed from 1 to 0. Run the RECONFIGURE statement to install.


BTW: I am using sql 2000
0
sammySeltzerAuthor Commented:
When I did response.Write as indicated earlier, I got this:

exec master.dbo.xp_cmdshell 'xcopy z:\HW6\AllPhotos\\thumbnails\2007\9\1139468T.JPG c:\inetpub\wwwroot\ImageFile\'

When I ran this in query Analyzer, I got the following error:
Invalid drive specification
0 File(s) copied
NULL

Another note, the xp_cmdshell has this as part of the stored proc:

exec master.dbo.xp_cmdshell 'net use z: \\servername\wwwroot'

So, it may be that the connection between this stored proc and the exec... is off, no?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

sammySeltzerAuthor Commented:
Can someone please help?

This is really urgent!
0
vs1784Commented:
Check if it is mounting the drive properly or not?
0
sammySeltzerAuthor Commented:
sorry, I do not quite understand what you. Can explain please, if possible with an example?

For instance, there are 3 processes involved here.

1, the stored procedure I showed:

exec master.dbo.xp_cmdshell 'net use z: \\servername\wwwroot'
2, A mapped drive to z: like this:

\\servername\wwwroot\HW6\AllPhotos\Thumbnails\

Then,
3),
sql_copy = "exec master.dbo.xp_cmdshell 'xcopy z:\HW6\AllPhotos\thumbnails\" & str2 & " c:\inetpub\wwwroot\ImageFile\'"
 
I believe that if there is a disconnect, it is occurring between the 3.

Thanks a lot for your assistance.
 

0
vs1784Commented:
net use z: \\servername\wwwroot this will mount a Drive to Z:

Check to see if it is mounting propelry and you can access Z: drive from Windows Explorer or not.

Try running this command from command line in windows and see if it gives any error or not.

Then run XCOPY command from command line and see if it works or not.

If any of above doesnt work in command line you have to check your windows settings instead of SQL or ASP.

If these goes throught from cmd and not from SQL Query analyzer, post the errors it throws.
0
sammySeltzerAuthor Commented:
I run the net use z:\servername\wwwroot - of course replacing servername with real name and I get the following error.

System error 85 has occurred.
The local device name is already in use.

Then I run the xcopy command and I get error message below.
File not found - 1139468T.JPG
0 File(s) copied
0
vs1784Commented:
That means the file you are trying to copy is not present and the Z: drive is already mounted .

May be you can right click on Z: Drive from Windows Explorer and disconnect it and try agian. I think it is mounted on wrong location.

0
sammySeltzerAuthor Commented:
The big mystry here is that it sees the image in the remote server:

'xcopy z:\HW6\AllPhotos\\thumbnails\2007\9\1139468T.JPG but copying it to the local drive here:

c:\inetpub\wwwroot\ImageFile\ appears to be the problem.

As you can see, the z:\ mapping is fine.
0
vs1784Commented:
Do you have rights to write in to that directory?
0
sammySeltzerAuthor Commented:
Yes, This is the directory that my application resides.

My application goes to the remote server (the server that is mapped to z drive), grabs the image I showed and then dumps it to the server where my application resides.

So, the issue is that there is something, I think, on the remote server that is preventing the xcopy from copying that image over to the directory where my app resides.

I hope this explanation makes sense.
0
vs1784Commented:
The user who is copying the file must have pproper rights to Read the file from remote server and write to local machine.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.