Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 Batch job tuning sgandhla Testing & Performance analysis 0 Fri Mar 24, 2017 9:41 pm
No new posts MIPS/CPU consumption reduction in Batch vishwakotin DFSORT/ICETOOL 4 Sat Mar 18, 2017 5:46 pm
No new posts Overlay the system date Danielle.Filteau SYNCSORT 4 Fri Mar 03, 2017 1:16 am
No new posts Calling procedure with multiple entri... steve-myers PL/I & Assembler 5 Fri Jan 27, 2017 3:33 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us