LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 06-19-2003, 07:16 AM   #1
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 425
Blog Entries: 1

Rep: Reputation: 36
java and system calls


Hi everyone, every time I try to do a system call that has inside some variable e.g:

helloWorld6Today is a C compiled program, imagine I have one for each day of the month.

String day=new String();
giveMeDay(day); --say it gives 6

Process egin=r.exec("/home/aizkorri/froga/helloWorld"+day+"Today");
egin.waitFor();


It just doesn't do anything, but If I do:

Process egin1=r.exec("/home/aizkorri/froga/helloWorld6Today");
egin1.waitFor();


It works.
And I think that it's pretty usual to use variables in that kind of calls, so do you have any idea what could be the problem?.
 
Old 06-19-2003, 07:22 AM   #2
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
Try putting spaces in the string and see if it works


Process egin=r.exec("/home/aizkorri/froga/helloWorld "+day+" " +Today);

Last edited by Looking_Lost; 06-19-2003 at 07:24 AM.
 
Old 06-19-2003, 07:50 AM   #3
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 425
Blog Entries: 1

Original Poster
Rep: Reputation: 36
hi, well, but the file name doesn't have spaces, anyway, it doesn't even try to execute anything.
 
Old 06-19-2003, 08:52 AM   #4
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
I see what you mean - I was reading it as two different parameters rather than one.

Only thing I can think of is giveMeDay is return a value you aren't expecting but I guess you've already checked that

I take it in the first example egin.WaitFor() returns a non-zero value showing there's been an error and at least it's tried to execute it.
 
Old 06-19-2003, 09:53 AM   #5
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 425
Blog Entries: 1

Original Poster
Rep: Reputation: 36
thanks a lot, I found the error, it returns 1 but I forgot to put an important thing in the example: it does not work if I do:

Process egin=r.exec("/home/aizkorri/froga/helloWorld"+day+"*Today");
egin.waitFor();

Without the * it works fine, I was trying to execute more than one application at the same time but the * gives an error, I don't understand why, but it does.
 
Old 06-19-2003, 11:23 AM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Quote:
Originally posted by aizkorri
Without the * it works fine, I was trying to execute more than one application at the same time but the * gives an error, I don't understand why, but it does.
I guess that's because the Java Virtual Machine does no use a shell to execute your command. The interpretation ("expansion") of wildcards ( * ? [a-z] ...) is always done by a shell.
 
Old 06-20-2003, 02:54 AM   #7
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 425
Blog Entries: 1

Original Poster
Rep: Reputation: 36
thanks for the explanation
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell example using system calls djgerbavore Programming 7 03-06-2010 03:39 AM
Making system calls in C++ harisund Programming 4 11-26-2005 06:58 PM
Some system calls Spooky Programming 1 11-24-2004 11:17 AM
system calls in Java AMMullan Programming 2 04-14-2004 02:48 AM
Number of system calls vladmihaisima Linux - General 2 10-02-2002 03:36 PM


All times are GMT -5. The time now is 03:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration