Showing posts with label share. Show all posts
Showing posts with label share. Show all posts

Monday, March 26, 2012

ftp command help

I need to schedule copying of files to an ftp share using a SQL agent
job..but i dont know how to do that in one step
Say for eg: the source of files are on \\computerA\share1\*.*
and the destination is an ftp site ftp.x.com with a username and password
And i want to run this job on say computerB.
Then what would be the command ?
ThanksYou can either
1) create a DTS package (FTP task) then schedule the job by using
'dtsrun' command in the job.
2) use native ftp cmds in the job (jobs steps in an order). e.g.
ftp ftp.x.com
cd (to the location)
put <file>
dir (check if the file there)
close (close the connection)
bye
Mel

ftp command help

I need to schedule copying of files to an ftp share using a SQL agent
job..but i dont know how to do that in one step
Say for eg: the source of files are on \\computerA\share1\*.*
and the destination is an ftp site ftp.x.com with a username and password
And i want to run this job on say computerB.
Then what would be the command ?
ThanksYou can either
1) create a DTS package (FTP task) then schedule the job by using
'dtsrun' command in the job.
2) use native ftp cmds in the job (jobs steps in an order). e.g.
ftp ftp.x.com
cd (to the location)
put <file>
dir (check if the file there)
close (close the connection)
bye
Mel

Wednesday, March 21, 2012

from sql - checking if a file exists in a given share

Hi,
from sql, what is the best way to check if a file exists in a share - given
the file's partial name (for example the first 20 characters) ?
I thought about saving the result set of "xp_cmdShell dir shareName ... "
into a temp table and query the temp table for the filename... but are there
better ways that do not require xp_cmdShell (that needs special permissions
to execute)?
ThanksYou could try using the sp_OA* procedures and the FileSystemObject in VBS.
ML
http://milambda.blogspot.com/|||This sounds interesting. Could you please point me to where I can find
sample code?
Thank you.
"ML" <ML@.discussions.microsoft.com> wrote in message
news:D4DE0DE1-BA83-4810-B385-FC6005DE4B45@.microsoft.com...
> You could try using the sp_OA* procedures and the FileSystemObject in VBS.
>
> ML
> --
> http://milambda.blogspot.com/|||A few samples are available in Books Online, the rest comes down to your
experience with VBS.
This sample demonstrates the use of the sp_OA* procedures:
http://msdn.microsoft.com/library/d...r />
_2ktw.asp
ML
http://milambda.blogspot.com/|||If your on 2005, you could do a UDF such as:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.IO;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static bool FileExists(string path)
{
return File.Exists(path);
}
};
William Stacey [MVP]
"Ramadan" <noOne@.hotmail.com> wrote in message
news:eIcSTaPAGHA.532@.TK2MSFTNGP15.phx.gbl...
> Hi,
> from sql, what is the best way to check if a file exists in a share -
> given
> the file's partial name (for example the first 20 characters) ?
> I thought about saving the result set of "xp_cmdShell dir shareName ...
> "
> into a temp table and query the temp table for the filename... but are
> there
> better ways that do not require xp_cmdShell (that needs special
> permissions
> to execute)?
> Thanks
>|||You can check this via the undocumented procedure (but be aware that
this is undocumented, not supported and could be deppricated in further
versions):
http://www.sql-server-performance.c..._procedures.asp
xp_fileexist
You can use this extended stored procedure to determine whether a
particular file exists on the disk or not. The syntax for this xp is:
EXECUTE xp_fileexist filename [, file_exists INT OUTPUT]
For example, to check whether the file boot.ini exists on disk c: or
not, run:
EXEC master..xp_fileexist 'c:\boot.ini'
HTH, jens Suessmeyer.sql