Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
C/C++ system() function calling shell script (batch)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: C/C++ system() function calling shell script (batch)
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

Site Director


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

PostPosted: Tue Mar 24, 2009 5:37 am    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Mar 24, 2009 8:59 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Mar 27, 2009 7:31 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Mar 28, 2009 4:24 am    Post subject: Reply to: C/C++ system() function calling shell script (batc
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts Generate public-private key in batch ... vasanthz All Other Mainframe Topics 3 Fri Sep 15, 2017 9:20 am
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts Calling CLIST through job and REXX Sahasra K CLIST & REXX 19 Tue Aug 01, 2017 10:25 am
No new posts Unable to copy data from spool in a d... srikant314 JCL & VSAM 8 Fri Jul 28, 2017 9:10 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us