Thread: Calling other scripts

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    23

    Calling other scripts

    I have two scripts that analyze data, now I'd like to have one script that calls each of these two scripts. I can't just copy and paste the code from each script into one because the location of each script is important.

    I would just like to know the function or the format in which you can call in other scripts to be run. Overall I want to call these two scripts which will analyze the data, then have that analysis printed onto a text document.

    Is that understandable?

    Thanks in advance!
    DC

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    For just calling another program within your own program, use system().

    If you also need to process the result from the other program you need some communication between both programs. If the other program is able to read the data from a file and save its output to a file it's pretty easy.
    There are also other forms of inter-process communications (IPC).

    Bye, Andreas

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    If you have two standalone programs that you want to run, you may be better off just writing a bash or shell script to execute them both. It will be simpler, especially if you're just running one program and feeding its output to another program. Examples:
    Code:
    #!/bin/sh
    dir1/analyze > intermediate.txt
    dir2/format < intermediate.txt > formatted.txt
    Code:
    #!/bin/sh
    dir1/analyze | dir2/format > formatted.txt
    etc.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need Help with scripts for a game!
    By LubuKage in forum Game Programming
    Replies: 5
    Last Post: 07-12-2010, 07:27 PM
  2. about cgi scripts
    By xixpsychoxix in forum Networking/Device Communication
    Replies: 11
    Last Post: 07-08-2008, 06:03 PM
  3. C++ for CGI scripts
    By sean in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-03-2003, 10:53 AM
  4. CGI scripts in c/c++ ?
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-14-2001, 01:24 PM