I have a Stored Procedure in which I'm mapping a Network Share Drive as a P:Drive and now I would like to remove the mapping and give the UNC path with both the username and password. Can someone please help me out in doing that?
EXEC xp_cmdshell 'net use P: "\\usanfsd01\Data" User1 /user:user /Persistent:Yes'
DECLARE #cmd varchar(4000)
DECLARE #path varchar(2000)
SELECT #path='P:\*.csv'
SELECT #cmd = 'Dir "' + #path + '"'
not sure if i really understand what you want to do, but to delete the mapping you would use
EXEC xp_cmdshell 'net use P: /delete'
Related
I am having trouble figuring out the correct Syntax for the File Path
SELECT c1.Produkt,c2.Name
from Reservation c1
left join [Articles.mdb].[Articles] c2 on c1.Produkt=c2.Produkt
group by c1.Produkt,c2.Name
It now searches for the Articles.mdb inside the Application Folder . I would like to specify the path , for example c:\database\articles.mdb . But unfortunately I cannot figure it out how to do it.
I tried [c:\database\articles.mdb] and ['c:\database\articles.mdb'] , either get Incorrect Parameter, or Incorrect Filename .
Please help.
UPDATE :
after removing Parameter Check from TADOQuery . And entering the text like this :
left join [c:\Articles.mdb].[Articles] c2 on c1.Produkt=c2.Produkt
It works.
I have stored procedure which should read CSV files from a Network Shared Drive in order to do BULK INSERT. I'm specifying the UNC path of Network Shared Drive using the variable #path. As the Network Shared Drive is secured, I need to pass the login information too and I'm not sure how to do that, can someone please help.
Below is what I have done so far
DECLARE #cmd varchar(4000)
DECLARE #path varchar(2000)
SELECT #path='\\usanfsd01\Data\*.csv'
SELECT #cmd = 'Dir "' + #path + '"'
You could map the network drive using a domain account that has permission on the network path then modify your query to pull from the mapped drive.
I use this code to log the many lines (SQL.Add) making complex scripts i have to build:
Ex:
[...]
SQL.Add('ENTITY_ID, PRO_CODE, PHASE_CODE, TASK_CODE, PERIOD_REF');
SQL.Add('from ' + trim(SourceJrnl) + ' where');
SQL.Add('MASTER_ID = ' + IntToStr(TranID) + ' and');...
[...]
{ for debugging only }
for i := 0 to SQL.Count-1 do
ShowMessage('Line #' + IntToStr(i+1) + ' : '+ SQL.Strings[i]);
Any simple way (function) to have the lines written to a file out of a stringlist or memo.
[EDIT] Sorry. NO memo or stringlist but a simple log file.
Calling SQL.SaveToFile will write the query to a file, but it will clobber the previous file contents, so you can only see one query and no other logs. Instead, read the SQL.Text property to get all the lines in a single string, and then write it to your log file using whatever logging technique you have for the rest of your program. In a pinch, a simple way to write a line of text to a file is to call Writeln, but people have asked about real logging libraries before.
When I want to upload anything in any form I see the Warning: escapeshellarg() has been disabled for security reasons message on my site. What can I do to fix this?
My framework is codeigniter final version.
Here is the full warning:
A PHP Error was encountered
Severity: Warning
Message: escapeshellarg() has been disabled for security reasons
Filename: libraries/Upload.php
The # operator will silence any PHP errors the function could raise. You should never use it!
Solutions:
Remove the escapeshellarg string from the disable_functions in php.ini file
Ask your host provider to remove Remove the escapeshellarg string from the disable_functions in php.ini file if you don't have an access to the php.ini file
make your own escapeshellarg. The function only escapes any single quotes in the given string and then adds single quotes around it.
function my_escapeshellarg($input)
{
$input = str_replace('\'', '\\\'', $input);
return '\''.$input.'\'';
}
and do something like this:
// $cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1';
$cmd = 'file --brief --mime ' . my_escapeshellarg($file['tmp_name']) . ' 2>&1';
But what is best is to extend the Upload.php library and override the _file_mime_type function instead of changing on the core of CodeIgniter so that you will not lose it if you ever want to update CodeIgniter.
Helpful links: https://www.codeigniter.com/user_guide/general/core_classes.html
Try
$cmd = 'file --brief --mime ' . #escapeshellarg($file['tmp_name']) . ' 2>&1';
Open Upload.php file from system/libraries folder and put # in front of escapeshellarg($file['tmp_name']) at line 1066
and second thing upload this file under application/libraries folder that will be better, other wise no problem, you can replace system's Upload.php file.
Remove the escapeshellarg string from the disable_functions at php.ini* file
Ask your hosting provider to remove the string above if you don't have an access to the php.ini* file
Change hosting provider which allows the running of the escapeshellarg function.
from this website: http://www.2by2host.com/articles/php-errors-faq/disabled_escapeshellarg/
Another simple way to solve this issue is just move your application from development to production:
Open index.php in your application root and change
define('ENVIRONMENT', 'development');
to
define('ENVIRONMENT', 'production');
I have the following values in a DOS batch file (for example...):
..\Apple\Jones
..\Banana\Smith
..\Pear\Wilson
I need to extract the last name values ("Jones", "Smith", "Wilson") from each value. What one technique can I use that will always give me these substring values?
According to this topic : What is the best way to do a substring in a batch file?
I suggest you to use
%~n0
I already wrote a function for that. You give it any path and it returns you only it's filename or pathname. Works for any path: Url, Windows path, Unix path, etc...
Copy this function at the end of your batch script: (Instructions below)
rem ===========================================================================
:Name_From_Path
SetLocal
set _TMP_FOLDERNAME=%1
for %%g in ("%_TMP_FOLDERNAME%") do set _TMP_FOLDERNAME=%%~nxg
EndLocal & set _Name_From_Path=%_TMP_FOLDERNAME%
goto :EOF
rem ===========================================================================
Usage:
CALL :Name_Of_Path ..\Apple\Jones
ECHO %_Name_From_Path%
Result: Jones