calling a program (w/ params) from within shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting calling a program (w/ params) from within shell
# 1  
Old 10-06-2008
calling a program (w/ params) from within shell

Hi all,

I need to call some script (s1) from within my shell script (s2). s1 accepts parameters and I want to feed it with values of params from my script. I tried many things but none work (I am so much of a beginner), please help

one of my attempts :
.
.
.
param1="hehe"
param2="haha"

s1
echo -e "\r"
echo $param1
echo $param2

------------------------------------------------------------------------------------
PS: when I run s1 from command prompt (not from shell I do the following and it works)
>s1 ; I press return key
>enter value of param1: hehe ; I enter hehe then return key
>enter value of param2: haha ; I enter haha then return key

-------------------------------------------------------------------
# 2  
Old 10-06-2008
hi,

please make your requirement a bit clear so that we may able to help you in writting the script.
# 3  
Old 10-06-2008
Oh I'm sorry

I am trying to write a script (s1.sh) which calls another script that I didn't write (s2).

Usually I run s2 from the command line as:

> s2 param1=val1 param2=val2 param3=val3

how do I call s2 from my shell script s1.sh and specifiy the values of the parameters?
I hope I am more clear now, thanks for the help in advance
# 4  
Old 10-06-2008
hi,

you can simply call the script s2 in the script s1.sh by simply mentioning

./s2.sh inside the script s1.sh

if your script s2.sh works fine on the command prompt then you will get the desired output.

thanks,
Subhendu
# 5  
Old 10-06-2008
Subhendu

Actually I tried that before and it didn't work either
I don't know the extention of s2. All I know that it's an executable now Smilie

Help
# 6  
Old 10-06-2008
Have You tried

./s2.sh $param1 $param2

then they will be available as $1 and $2 in s2.sh

/Lakris
# 7  
Old 10-06-2008
Ok. I just found out that s2 is prolly written in fortran because there are files on my machine as s2.f and s2.o
is it possible to call it from my script at all?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Program crashes on calling __libc_msgrcv()

Hi, I am a newbie to linux programming. I have implemented msgqueue in C. msgrcv() call at the client end is as below: msgrcv( msgqid, msgptr, msgsize, msgtype, 0 ); My program works fine when msgrcv () from /lib/libc.so.6 is called. However it crashes when __libc_msgrcv() is called. ... (3 Replies)
Discussion started by: praasanna
3 Replies

2. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

3. Shell Programming and Scripting

Calling perl script in shell program

How to call a perl script in shell program / shell scripting. PLS HELP ME (2 Replies)
Discussion started by: hravisankar
2 Replies

4. Programming

Calling a shell script from a C program

Hi, I have a shell script which connects to a database and fetches the count of the records from a table. I want to embed this whole script in a C program. Also the count fetched should be available in the C program for further usage. Please let me know how this can be done. Thanks (9 Replies)
Discussion started by: swasid
9 Replies

5. Shell Programming and Scripting

Calling a shell script from a C program

Hi, I have a shell script which connects to a database and fetches the count of the records from a table. I want to embed this whole script in a C program. Also the count fetched should be available in the C program for further usage. Please let me know how this can be done. Thanks ... (0 Replies)
Discussion started by: swasid
0 Replies

6. Shell Programming and Scripting

Run shell script from C program by calling fork and execl

I need to write a c program that uses the fork and excel system calls to run the shell script mode invoked like this: "./mode 644 ls -l" (that is the argumetns will always be 644 ls -l) here's the mode script: #!/bin/sh octal="$1" shift find . -maxdepth 1 -perm $octal -exec $@ {} \; ... (3 Replies)
Discussion started by: computethis
3 Replies

7. UNIX for Advanced & Expert Users

calling a Universe program

Can someone offer some technical advice concerning an call to a IBM U2 (Universe) program? When I use the following script from a unix shell, it works fine: $ " xxx.sh " (contains the following --->) 1. cd /links/ACCOUNT1 2. /shapps/ibm/uv/bin/uv "COUNT FILE1" ... (2 Replies)
Discussion started by: smintz
2 Replies

8. Shell Programming and Scripting

Calling Functions of Other K Shell Program

Hi, I have a K shell a.ksh function abc { // Some logic } In b.ksh i have included the a.ksh ./a.ksh I want to call the abc function from this b.ksh script. Thanks Vijay (2 Replies)
Discussion started by: vijaykrc
2 Replies

9. UNIX for Advanced & Expert Users

calling program

hi, i have a script.sh on my machine and it used in the system but my question is how can i know the program called this script.sh?? i.e. from where it called and execute?? Many thanks (1 Reply)
Discussion started by: alzuma
1 Replies

10. Shell Programming and Scripting

Calling SHELL script from C program

Hi, I just tried to call a simple script from a pretty simple C program. I could not succeed :-( a message was thrown saying "sh: line 1: "Script name with path": Permission denied" The C program and shell script are below, both are in the same directory and shell script is given... (7 Replies)
Discussion started by: Chanakya.m
7 Replies
Login or Register to Ask a Question