?
Solved

Unable to copy image from remote server to another server

Posted on 2008-02-07
13
Medium Priority
?
839 Views
Last Modified: 2008-02-19
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

0
Comment
Question by:sammySeltzer
  • 7
  • 6
13 Comments
 
LVL 11

Expert Comment

by:vs1784
ID: 20843387
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
 
LVL 29

Author Comment

by:sammySeltzer
ID: 20843456
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
 
LVL 29

Author Comment

by:sammySeltzer
ID: 20843537
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 29

Author Comment

by:sammySeltzer
ID: 20844629
Can someone please help?

This is really urgent!
0
 
LVL 11

Expert Comment

by:vs1784
ID: 20844673
Check if it is mounting the drive properly or not?
0
 
LVL 29

Author Comment

by:sammySeltzer
ID: 20844773
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
 
LVL 11

Expert Comment

by:vs1784
ID: 20844998
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
 
LVL 29

Author Comment

by:sammySeltzer
ID: 20845238
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
 
LVL 11

Expert Comment

by:vs1784
ID: 20845283
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
 
LVL 29

Author Comment

by:sammySeltzer
ID: 20845574
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
 
LVL 11

Expert Comment

by:vs1784
ID: 20845689
Do you have rights to write in to that directory?
0
 
LVL 29

Author Comment

by:sammySeltzer
ID: 20845891
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
 
LVL 11

Accepted Solution

by:
vs1784 earned 200 total points
ID: 20846113
The user who is copying the file must have pproper rights to Read the file from remote server and write to local machine.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question