Ok so ive reached the end of my knowledge and have tried to find out how to do it and just plain dont understand it.
I have a system call: -
system("db2cmd.exe \"db2 connect to vop9 user joebloggs using joesPassword&&db2 LOAD FROM \"d:\\vop9\\records_test.csv\" OF DEL MODIFIED BY COLDEL; METHOD P (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17) MESSAGES \"D:\\vop9\\output.txt\" INSERT INTO UKVOICE.CALLDATA (ID, REFERENCE, RECORDTYPE, NASIP, TIMESTAMP, USERNAME, SOURCEID, DESTUSERNAME, DESTINATIONID, SGWIP, DGWIP, H323SETUPTIME, H323CONNECTTIME, H323DISCONNECTTIME, CONNTIME, DISCONNTIME, DURATION) NONRECOVERABLE INDEXING MODE AUTOSELECT&&db2 connect reset&&exit\"\n")
-
It calls a DB2 command window: "db2cmd.exe" with parameters to connect to a DB and then load data from a .csv file reset the DB connection and exit the DB2 command window. This takes some time.
I then need it to move the csv to another location. I am currently using a simple system command:
system("move xyz.csv folder1");
However my perl script opens the DB2 part and then leaves it to run then goes straight onto executing the move command. Before you know it, the file is moved and is no longer there for the data to be transfered to the database.
Can anyone enlighten me as to how to wait for the system first system command to complete before moving onto the next one?
James
8 10315
Welcome to TSDN James!
First, I cleaned up your post a touch by adding code tags around your...well....code. Whenever you post code, enclose it in code tags. The example of the tags is on the right of your Message window in the REPLY GUIDELINES box. if you set the initial code tage to be code=perl, enclosed in square brackets, then the forum will syntax highlight your code for Perl.
Second, if you could post your code here (more than just the system command), then we will be able to look at your script and see what is going on.
Thanks!
Jeff
well lookee here:
numberwhun Moderator
you have my sympathies Jeff ;)
well lookee here:
numberwhun Moderator
you have my sympathies Jeff ;)
Yes, yes, Thank you! Actually, I am quite please with it and am enjoying being able to help out more. Although, the sympathies are still accepted for when I am having rough days. ;-|)
Jeff
Yes, yes, Thank you! Actually, I am quite please with it and am enjoying being able to help out more. Although, the sympathies are still accepted for when I am having rough days. ;-|)
Jeff
In all seriousness, I thought you would be a good forum moderator and I guess the staff of this forum was waiting for you to get your post count up to invite you to be one. Maybe not, I have not heard anything from Mary or any of the other staff. Maybe they have just been busy. I am sure Miller will appreciate the company. Keeping the unwashed masses in line is a constant struggle. ;)
Enjoy moderating and congratulations.
-Kevin
PS: you still have my most sympathetic sympathies :)
Actually, I approached Miller via PM a couple of weeks ago. He has been busy and unable to get to many things, but he was able to put the request in the other day and voila, a birthday present for me. :-)
I will enjoy it, and thanks!
Jeff
Can anyone enlighten me as to how to wait for the system first system command to complete before moving onto the next one?
James,
The system command is a blocking operation, so it will automatically wait until the child process i completed. This means that your first command most likely is not working correctly, and that is the source of your problem.
I suggest that you clean up your code a little by using qq{} as your string delimiter instead of "". This would prevent the need to escape all of double quotes. Additionally, since you have no variables that need to be interpolated, it would probably be even better to use q{} instead.
Just note that creating a system command that uses parameters can be complicated since the escaping can be tricky. You must escape things on the perl level, and also on the system level.
- Miller
Hi there,
afaik this is a DB2 item and not perl related: - system("db2cmd.exe \"db2 connect to vop9 ...
db2cmd spawns off and starts running in a separat address space, so that the system() call returns.
Regards, Bernd
Hi again,
usually I'm working on Linux systems and am using bash shell scripts, but something like this could work with perl on Window$, too (in very rough perl code): -
open( MYPIPE, " | db2cmd.exe "); # (pipe to db2cmd.exe) for output
-
print MYPIPE "
-
db2 connect to mydb
-
db2 load from ...
-
db2 connect reset ";
-
close(MYPIPE);
-
Maybe you've got to use the "db2" command instead of db2cmd.
Regards, Bernd
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JS |
last post by:
Can somebody explain how to get the tablespace out of quiesce mode?
I am executing on each node of my EEE Win2K system:
db2 quiesece tablespace for table schema.tablename RESET
I get the...
|
by: Allan Adler |
last post by:
In C, I can execute
system("gs gleep.ps");
and have C run a ghostscript program gleep.ps, which might ask for user
input and, when it gets it, take some actions and report back to the
C...
|
by: Rodusa |
last post by:
I am getting this exception error which is driving me nuts.
System.NullReferenceException - Object reference not set to an instance
of an object
If I comment this line, I don't get any errors:...
|
by: Hugh Janus |
last post by:
Hi group,
I am executing a shell command that calls a .BAT file. I have to wait
for this batch file to finish so I use the wait = true parameter in the
shell command. However, this means that...
|
by: =?Utf-8?B?Z215ZXJz?= |
last post by:
Hello,
I am attempting to start a cmd.exe process and pass several .vbs scripts
(with additional parameters) and then read the output from the scripts and
make "notes" in a DataTable (the...
|
by: pavi |
last post by:
Hi,
I am using system command to execute a shell script in a C
program.
Usage system("sh file").
There are situations where the file may be empty. But
execution gets hung if the
file is empty....
|
by: Saya |
last post by:
Hi Folks,
I have now spend app. 3 days to get the below scenario to work, but
can not get there!
..Net version = 2.0.50727
Windows version = Microsoft Windows = Windows
Server 2003
Now I...
|
by: tom_kuehnert |
last post by:
Hi!
I'm trying to execute a program using system(). The program itself is
located in some path which might contain whitespaces.
Simple solution would be this:
system("\"C:\A B\C.exe\"");
...
|
by: =?Utf-8?B?UGF1bCBQb2xpY2FycA==?= |
last post by:
I'm attempting to make an application that will call and execute multiple
"system()" cmd commands simultaneously. The problem is that when the program
hits the first system() it waits for it to...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |