IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

C/C++ system() function calling shell script (batch)


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
HenriqueS

New User


Joined: 17 Feb 2007
Posts: 30
Location: Brazil

PostPosted: Tue Mar 24, 2009 5:27 am
Reply with quote

Hello,

I´ve tried to call a shell script using the system() function (ex.: system('/tmp/script.sh') but I am getting RC=256. The script has executable attributes (+x) so I have no idea what is going on.

I printf the command line that is passed to the system() function, cut and paste into a Unix terminal window and it runs w/o problems.

Any clue?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 24, 2009 5:37 am
Reply with quote

Hello,

You might try:
Code:
system(sh '/tmp/script.sh')
or
Code:
system('sh /tmp/script.sh')
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Mar 24, 2009 6:50 am
Reply with quote

HenriqueS,
It's considered bad form to post the same question on 2 different bulletin boards within an hour of each other. icon_evil.gif
Back to top
View user's profile Send private message
HenriqueS

New User


Joined: 17 Feb 2007
Posts: 30
Location: Brazil

PostPosted: Tue Mar 24, 2009 7:47 pm
Reply with quote

sorry.

Terry Heinze wrote:
HenriqueS,
It's considered bad form to post the same question on 2 different bulletin boards within an hour of each other. icon_evil.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 24, 2009 8:59 pm
Reply with quote

Hello,

Quote:
I always thought that ibmmainframes.com and READ FORUM RULES.com had different people showing up, sorry
Why would this make a bad practice acceptable? It is ok if no one sees it icon_confused.gif No, it isn't. It is still quite inconsiderate to post the same question multiple places. . .

Is the rc=256 now resolved/working?
Back to top
View user's profile Send private message
HenriqueS

New User


Joined: 17 Feb 2007
Posts: 30
Location: Brazil

PostPosted: Fri Mar 27, 2009 4:10 am
Reply with quote

No it is not working, there is something really strange going on.

I have jdk 6 (64 bit) installed here. in a few lines:

DOES RUN
Code:

sprintf(cmd, "/bin/java -cp .:jcifs-0.7.9.jar CopyFile %s %s > /tmp/out", source, dest);
system(cmd)



DOES NOT RUN
Code:

sprintf(cmd, "/bin/java -cp .:jcifs-1.2.25.jar CopyFile %s %s > /tmp/out", source, dest);
system(cmd)


Data:
1) The running sample uses an old JCIF library (library that allows access to windows network shares), the CopyFile program was made originally to run with this lib version (0.7.9).

2) The sample that does not run uses a newer JCIFS library and a different CopyFile program that does a few differente method calls since these calls changed in the new version of the JCFIS lib.

Now the STRANGE stuff:
1) When I run the command line on the Unix prompt, using the newer library and the update CopyFile program, it DOES RUN. Actually I made my C program to print out which command line will be executed under the system() call, so I just copy from the SYSOUT and paste into the USS prompt.

2) the /tmp/out file that is supposed to record any stacktraces or error conditions is created fine with the first (older) program, but not in the second program. In fact, when the second program runs, the /tmp/out file is just 'touched' (a 0-byte file with the current timestamp as creation date).

3) All the error conditions I made on the 2nd program do not exit with a RC 256, but other numbers such a 0, 8 and 16.

dick scherrer wrote:
Hello,

Quote:
I always thought that ibmmainframes.com and READ FORUM RULES.com had different people showing up, sorry
Why would this make a bad practice acceptable? It is ok if no one sees it icon_confused.gif No, it isn't. It is still quite inconsiderate to post the same question multiple places. . .

Is the rc=256 now resolved/working?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Mar 27, 2009 7:31 am
Reply with quote

Hello,

Is it possible that there is a path difference/discrepancy in the different executions? If my memory is working, a file in the current directory would be used before the path was searched (on HP-UX years ago - repeat, if my memory is working).

Can you rename the problem module to ensure the desired code is being executed?

You might check the permissions on the new components. Especially if anything is supposed to have the "sticky bit" turned on.

Sorry but it's been too long. . .
Back to top
View user's profile Send private message
HenriqueS

New User


Joined: 17 Feb 2007
Posts: 30
Location: Brazil

PostPosted: Sat Mar 28, 2009 3:38 am
Reply with quote

Dick,

Thanks for your feedback, I made think and compare the file permission for the new .class (CopyFile program) and .jar files (JCifs library).

I figured out that the file permissions were not OK, I did set a chmod 755 for these new files and the job executed like a charm.[/b]
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Mar 28, 2009 4:24 am
Reply with quote

Cool - good to hear it is working icon_smile.gif

Thank you for letting us know icon_wink.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Sysplex System won't IPL at DR site I... All Other Mainframe Topics 2
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts How to get a stack trace on a looping... ABENDS & Debugging 5
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts Calling an Open C library function in... CICS 1
Search our Forums:

Back to Top