I have a .bat file in which I insert data from csv to oracle using sqlldr but when I double click .bat file nothing happen.
But when I copy that in cmd and run it executes the data.
I don't know what happen any path mistake or anything.
Batch file
P:\Users\ashique.sheikh\VMI>sqlldr upi/upi DATA=P:\Users\ashique.sheikh\VMI\test.csv CONTROL=Insert.ctl LOG=Insert.log.
CTL File
OPTIONs(SKIP=1)
LOAD DATA
INFILE "P:\Users\ashique.sheikh\VMI\test.csv"
INSERT into table DETAIL
REPLACE
fields terminated by ','
(ID,NAME,ADDRESS,CITY,MOBILE)
try to use this line in the bat file:
start "" cmd.exe /c sqlldr upi/upi DATA=P:\Users\ashique.sheikh\VMI\test.csv CONTROL=Insert.ctl LOG=Insert.log
Some WinodwsXP has a problem as different SET variables when you run cmd.exe and another when you run .bat file. It was antivirus sandbox or something etc.
Try adding the path to the ctl parameter too. I'm afraid windows searches the path for insert.ctl and it doesn't find it.
Related
I want to download one zip file from web and unzipped and import that file to sas data set for further use.
For unzipping i use below sas code.. But result is nothing with no error.
data _null_;
x "cd C:\Program Files\7-Zip ";
X "7z.exe e C:\Users\Ravinder\Downloads\Compressed\*.zip -o C:\sasdata\New";
run;
Please help to do the same.
ravinder kumar
Have you tried running your command from a command prompt? Did it work? I would recommend running the command like this rather than changing the folder first:
"C:\Program Files\7-Zip\7z.exe" e C:\Users\Ravinder\Downloads\Compressed\*.zip -o C:\sasdata\New
When you run the above command from SAS use single quotes as your string delimiter for the command like so:
data _null_;
X '"C:\Program Files\7-Zip\7z.exe" e C:\Users\Ravinder\Downloads\Compressed\*.zip -o C:\sasdata\New';
run;
If it is still not working as expected from SAS, then the easiest way to debug IMO is to put the command in a batch file (.bat), and then at the end of the file put a line that simply says pause. The pause command will tell windows to keep the batch file window open until you close it. The window will give you full visibility of what happened when you ran the command. Try running the batch file from SAS instead of running the command directly.
Note that you may also need to specify the following SAS options if you want SAS to wait for the unzip to finish before your SAS program continues processing:
options noxwait xsync;
noxwait tells SAS to close the command window automatically once the command has run, and xsync tells SAS to wait for the command to finish running before continuing to process. Note that sometimes when extracting files, the command can finish but the file will still not exist on disk due to either network copying and/or caching. If you want to be absolutely sure, you should probably check for the existence of the file and/or tell sas to sleep() for a certain amount of time.
here is my problem solution.. File download to c:\sasdata location.
data _null_;
x "cd c:\sasdata";
x "curl -A 'Mozilla/4.0' -O http://nseindia.com/content/indices/histdata/CNX%20NIFTY&FRNAME-&FRNAME..csv";
run;
I am trying to run a batch file from a different program.
When I run the batch file manually (double clicking the file) it behaves as expected and creates a text file as a result. But when I call the batch file from a program (Winlog SCADA) the text file is not created.
Does anyone know why this happens?
The batch file contains this line of code:
systeminfo |findstr /C:"Time Zone" >UTCTime.txt
and the code that is calling the batch is (Winlog SCADA):
ShellExec(scriptPath,"run",projectPath+"/Settings/",8,".exe","");
The program probably writes to a different folder - try specifying the path to the folder where you want the file.
systeminfo |findstr /C:"Time Zone" >"c:\folder\UTCTime.txt"
Newbie to windows scripting. I need help running the .bat file on the command line so I can test it.
I used Text Document as my editor to create the file (opens up also as Notepad).
I performed file "save as" (ALL FILES). If I open up cmd, I can see the file has a .txt extension (myfile.bat.txt). So if I just type in cmd myfile.bat.txt the editor opens. I am not sure how to execute this correctly.
As for the logic in my batch script, I am basically logging into a remote directory (already created the net mount) and now I want to:
run an executeable file
rename some files.
With some research, I written this so far. I have saved it as a .bat file
# echo off
echo This is a batch file to run an executable and rename some files
pause
--run executable file here, just don't know how to do it
x:
cd x:
rename fileA fileB
Any help, good tips/practice would be great. Thanks.
Type in this command in cmd window:
rename myfile.bat.txt myfile.bat
Now you can run the script by simply invoking:
myfile.bat
or
myfile
(provided there's no myfile.exe or myfile.com in the same directory).
If you need to edit the script further, you can either right click it in Explorer and choose Edit or call the editor from the command window:
notepad myfile.bat
To call a program from the script, simply add its name, if it's in the current directory:
someprogram.exe
or the name with the path, if it's somewhere else:
directory\program.exe
or
d:\directory\program.exe
If the name or the path contain spaces, be sure to enclose the entire name & path string in double quotes:
"d:\directory\program name.exe"
you can just type the full name of the program
eg
"c:\program dir\program.exe"
or you can add the program directory to your path environment variable
set PATH=%PATH%;"c:\program dir"
and just type the program name
program
you can also edit your PATH variable in windows http://support.microsoft.com/kb/310519
NOTE: When you save the file in notepad, you want to save it as filename.BAT and select All Files from the second dropdown. If you don't it still gets saved as a .TXT.
A couple of command to consider:
CSCRIPT cscript /? in CMD
START http://ss64.com/nt/start.html
If you're doing say a VBSCRIPT use CSCRIPT to start it. If you're trying to execute another BATCH script or an EXE, use START
I created a simple install.bat file into my application folder, to execute its thing on windows.
But it only executes the first line of the .bat file.
Is there something that I need to add so it continues after the first one is done?
copy something somewhere
move something somewhereelse
gem install etc
Above are the type of commands that are in the .bat.
Do I need to anything something inbetween?
Is the first command in your batch file actually a copy command, or is it a command that's running another batch file?
Running a batch file from another by simply using the second batch file;s name will not return to the calling batch file.
If you want one batch file to invoke another and return you have to use the call command.
Are you overwriting a file? If so you'll need to add the /Y to the copy command to supress the prompt that asks if you want to overwrite the file.
Use the /h parameter to get help on the copy command. It will show this usage and some others.
As written above, all three lines will execute. I imagine that the second and third lines are failing. You should capture the output which will explain why those lines failed.
I would like to create a batch file which will move the output file of a custom command "mdmg C:\source i5". I must execute this command from the C:\home directory where the mdmg.cmd resides.
This command converts the any file in the source dir and creates an output files in the C:\home folder.
However I want to move the output files to another folder autometically, lets say C:\test.
can it be done in a batch script?
Thanks in advance.
bla.bat
move c:\home\* c:\test
What is the problem ? DOS has a move command. Or you could simulate that with a copy and delete if move is unavailable for some reason.
You could save yourself the trouble of the batch using CMD redirects. Just paste the following behind the mdmg.cmd command.
> "C:\source i5\output.txt"
Basically the CMD interpreter will execute the command(s) in mdmg.cmd, and then redirect the output of the commands to print in output.txt. This way you don't have to call another batch. Another cool thing about doing it this way is that if the output file does not exist at the specified path, cmd.exe will make it for you.