?
Solved

calling a script from c

Posted on 2000-03-07
9
Medium Priority
?
378 Views
Last Modified: 2010-04-02
hello,
i wrote a script named 'renamefile' that will execute 3 or 4 separate commands: (eg below)
  rm filename1
  rename filename2 filename1
  rename filename3 filename2

i would like to call this script inside my c program.  i'm using SCO Unix V as the platform.  i tried using the command
'system("./renamefile");' and it didn't work.  could anybody else give me suggestions.  thanks a bunch.

zandyl
0
Comment
Question by:zandyl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 3

Accepted Solution

by:
msmits earned 320 total points
ID: 2592461
You should either use the she-bang notation in your script or explicitly call a shell to execute your script.

The she-bang solution (rewrite script) and make sure the execute bits are on:

#!/bin/sh
rm filename1
rename filename2 filename1
rename filename3 filename2

Or the shell solution:

system("/bin/sh ./renamefile");

0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2592779
try you use
execl(...);
or all the same functions
0
 
LVL 3

Expert Comment

by:arnond
ID: 2594818
did you make sure that the 'renamefile' is executable ?
try to do 'chmod a+x renamefile'. this will make the file executable.

Arnon David.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 84

Expert Comment

by:ozo
ID: 2594841
also be sure that the `rename` is executable
0
 
LVL 3

Expert Comment

by:arnond
ID: 2594886
ozo, isn't that what I suggested ???

Arnon David.
0
 
LVL 5

Expert Comment

by:PC_User321
ID: 2594958
Try using full path names for rm and rename, in case the script does not inherit the correct environment.
0
 
LVL 5

Expert Comment

by:PC_User321
ID: 2594962
.. and to bypass any aliases that might apply to them.
0
 

Author Comment

by:zandyl
ID: 2596160
thanks msmits.  i tried it and it works!!

zandyl
0
 
LVL 3

Expert Comment

by:msmits
ID: 2598598
Which one of my solutions?

Thanx for the grade!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question