Hi,
I have a basic question regarding scripting.
I want to execute one script(child script) from another script(master script) and pass some values as well.
There are certain function present in master script that i want to use or call from child script. What all thinsg should i keep in mind while doing that?
In C , we use "include". Do we need to include the master script in the child script? if yes how?
How should i call function present in master script from child script?
Please use the CODE tags, its even available in quick reply.
Syntax:
Examples:
However, to actualy execute a script, one usualy uses sh for bash scripts.
If you use another shell for your scripts, you could verify the $SHELL variable inside your caller/mother script contains the proper value, and then simply execute another script of the same shell with this:
Of course, the files should contain a so called shebang, that is #!/bin/bash for a bash script.
And if the script has the execution flag, you dont even need to call it using a shell command, just invoke the script as 'path'.
Also note, that if you execute a script, you can pass arguments (if the script is designed to handle it), which IMHO should be prefered, but might depend on situation/usage.
Although it's an option, I'd recommend not executing a shell script with sh < myscript because disables all reading from the standard input (stdin) within the script.
K.
-- Apologies, I've just edited my comment because I've found a typo. I've just corrected it.
Last edited by Kibou; 04-25-2014 at 05:19 AM..
Reason: Correcting a typo
Hi,
I have 2 scripts, first.ksh and second.ksh and would like first.ksh to run based on response of 'Y/y' received for second.ksh but in my case it continues to execute 'rm /tmp/list' irrespective of response received, below are my scripts with further info,
Hope I'm making sense :)
Thanks!
... (1 Reply)
Hi team,
My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server.
I have completed the first part i.e From windows to using to unix server with the help of psftp.exe
code:
psftp user@host -pw password <... (1 Reply)
Hi team,
I have two select statements and need to run them using SYSDBA user
select * from temp_temp_seg_usage;
select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb from
dba_segments where segment_name='TEMP_TEMP_SEG_USAGE';
Need to run this using a shell script say named... (1 Reply)
Hi,
I am using solaris 10.Is there any way to execute the script with the scriptname wihtoug using ./scriptname?Also does it varies from shell to shell.I have scripts in bash,ksh,sh shells.
Example:script.sh is the script name.I need to execute the script like this script.sh instead... (4 Replies)
Hi
I have a bash script which takes parameters
sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC
gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash
I have... (0 Replies)
Hi,
I am new to the expect scripting.
I have this expect script as below :
spawn ssh remote_server -l id
set pass "12345"
set opt "s"
expect "Password:" {send "$pass\r" ; }
expect "*ENTER*" {send "Enter\r"; exp_continue }
expect "Please select option :" {send... (2 Replies)
Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh.
Thanks in advance (2 Replies)
Hi i have a script which is calling another script.
But my child script is displaying some values.
sample script.
export LOG_File=/log
$/Project/Scripts/emit.ksh
mv inner_test.ksh /log/test.ksh
echo 'Success'
here emit.ksh is doing some processing .and echoing some values.
what i... (2 Replies)
Hi all,
I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script?
Thanks
i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Hi,
I have used exec ("/bin/ksh -c /path/file.ksh arg1"); to execute the file.ksh script from a test.pl script. But it doesnt work.. can anyone tell me what exactly the systax should be?... i have tried system("/path/file.ksh arg1"); too....still no luck...
quick replies are highly appreciated (1 Reply)