473,698 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

system command not waiting

1 New Member
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:
Expand|Select|Wrap|Line Numbers
  1. 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")
  2.  
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
Aug 31 '07 #1
8 10363
numberwhun
3,509 Recognized Expert Moderator Specialist
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
Aug 31 '07 #2
KevinADC
4,059 Recognized Expert Specialist
well lookee here:

numberwhun
Moderator

you have my sympathies Jeff ;)
Sep 1 '07 #3
numberwhun
3,509 Recognized Expert Moderator Specialist
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
Sep 1 '07 #4
KevinADC
4,059 Recognized Expert Specialist
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 :)
Sep 1 '07 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
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
Sep 1 '07 #6
miller
1,089 Recognized Expert Top Contributor
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
Sep 3 '07 #7
docdiesel
297 Recognized Expert Contributor
Hi there,

afaik this is a DB2 item and not perl related:
Expand|Select|Wrap|Line Numbers
  1. 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
Sep 3 '07 #8
docdiesel
297 Recognized Expert Contributor
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):

Expand|Select|Wrap|Line Numbers
  1. open(  MYPIPE, " | db2cmd.exe ");  # (pipe to db2cmd.exe) for output
  2. print MYPIPE "
  3.   db2 connect to mydb
  4.   db2 load from ...
  5.   db2 connect reset ";
  6. close(MYPIPE);
  7.  
Maybe you've got to use the "db2" command instead of db2cmd.

Regards, Bernd
Sep 3 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

7
4256
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 confirmation that the SQL command has executed successfully on each node. But, it doesnt seem to do anything because when I try and query the table, I get "TABLE SPACE ACCESS NOT ALLOWED" This all resulted from trying to execute a load with the...
2
1704
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 program. I think I can probably handle that last step by having ghostscript write to a file and have the C program read the file. That's ok for one interactive program. Suppose I want to have two or more
17
9685
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: string Total_Dollar_Amount = GetTotal(sql,"test"); namespace SalesReport
6
7641
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 my app freezes causing the form is not be refreshed when something goes in front of it and then disappears. This looks ugly and gives the impression that the program has crashed. Any ideas how I can repaint my screen whilst waiting for the...
5
3448
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 "notes" not being the issue). Beginning with... Dim objProcess As Process Dim objProcessStartInfo As New ProcessStartInfo
3
2642
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. What might be the problem. Regards, Praveen Kumar A.S
5
3298
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 have to develop a webservice which is run on the server. The
12
3478
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\""); but now this program also has parameters which need to be passed (again with paths containing whitepaces)
9
3290
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 finish executing (and it can run indefinitely until dismissed with Ctrl+C) and only after it has closed does it move on to the next. Is there any way to make the program move on immediately after calling system(), without waiting for a return...
0
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.