Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Unable to run a shell script

    Scheduled Pinned Locked Moved SDK Help
    1 Posts 0 Posters 128 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 16/04/2006 at 05:01, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.5 
      Platform:      Mac OSX  ; 
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      I'm trying to get a COFFEE script to run a Bourne shell script. (See below if you want to know why.) I'm using GeExecuteProgram() and building a path to /bin/sh in a Filename object for the first parameter, and a path to my shell script in the same way for the second parameter. GeExecuteProgram() does return TRUE, but the shell script doesn't seem to actually run, so I wrote a simple C program to see what was happening:

        
      #include <stdio.h>  
        
      int main(int argc, char* argv[])  
      {  
          int i;  
          FILE* fp = fopen("/tmp/debug.txt", "w");  
          fprintf(fp, "argc: %d\n", argc);  
          for (i = 1; i < argc; ++i) {  
              fprintf(fp, "argv[%d]: %s\n", i, argv _);  
          }  
          fclose(fp);  
          return 0;  
      }  
      

      /tmp/debug.txt does indeed get created (proving that my GeExecuteProgram() code is getting run), but the file contains something very strange:

        
      argc: 2  
      argv[1]: -psn_0_19529729  
      

      Why is the first command line argument "-psn_..." instead of the path to my shell script?

      P.S. The reason I want to run a shell script is that seems to be the only way to run a program with many arguments, like this:

      /some/program/somewhere -a arg -b another_arg -c yet_another_arg stuff morestuff

      GeExecuteProgram() only takes a single argument, and it seems to validate that the second argument is actually a file, so you can't pass arbitrary text to it. So, I'm writing out the command I really want to run to a shell script and I want to run as a workaround for this.

      And yes, I'm aware that this is not portable. We already have the Windows side taken care of, using a similar hack. We use a batch file there, which works, because we can use GeExecuteFile(). That doesn't work on Mac, because files created by C4D are owned by C4D, so the OS always gives the file to C4D to run when we use this method. It doesn't look at the file extension like on Windows.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post