Finish current script and execute next script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finish current script and execute next script
# 1  
Old 02-13-2015
Finish current script and execute next script

Hi,
I've come accross a situation where I need to exit from current shell script at the same time I need to start/activate another shell script.

How can I do that in KSH ?? Need help !!

For example, my script is as below


Code:
#!/bin/ksh

paramFile="/home/someXfile.lst"

[[ $(grep `TZ=CST-24 date +%Y%m%d` $paramFile) -ne 0 ]] && <<Here I want to exit from this script and execute another script /home/someYscript.sh>>


I tried below but didn't work well

Code:
#!/bin/ksh

paramFile="/home/someXfile.lst"

pid=$$
[[ $(grep `TZ=CST-24 date +%Y%m%d` $paramFile) -ne 0 ]] && kill -9 $pid | /home/someYscript.sh

R0H0N
# 2  
Old 02-13-2015
Perhaps the exec command is what you need. Try this out:-
Code:
$ cat a.sh
echo "I'm in script a"
exec b.sh
echo "I'm still in script a!"

$ cat b.sh
echo "I'm in script b"

If we run it, we get:-
Code:
$ a.sh
I'm in script a
I'm in script b

Basically, this overwrites the current process (or shell) with what's being called. Does this do the sort of thing you want?



Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Who can finish this script?

Good morning dear friends, I want to write an UNIX script to do the following task: We have 6 directories, called (SMS_01, SMS_02 ....... SMS_06), some files are distributed across these directories, but the distribution process is not good, I mean when I check these directories I found the... (14 Replies)
Discussion started by: Mohannad
14 Replies

2. Programming

CGI Perl script to execute bash script- unable to create folder

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)
Discussion started by: rakeshkumar
0 Replies

3. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

4. Shell Programming and Scripting

expect ssh script cannot finish and exit

All i am new to linux, and try to have a simple expect script to ssh then telnet to the network equipment, and exit itself. but dont know why i hang at the last $ #!/usr/bin/expect set timeout 10 set arg set arg1 spawn ssh -l UserA 1.1.1.1 expect "assword:"; send "PasSwOrD\r";... (1 Reply)
Discussion started by: samoptimus
1 Replies

5. Shell Programming and Scripting

Execute commands from script in current bash session

I have a file as follows: cat /etc/mxg/ssh-hostsmx.example1.com.au:2225 mx2.example2.com.au:2225 mx.example3.com.au:2225 mail.example4.com.au:2225 mail.example5.org.au:2225 mail.example6.com.au:2225I want to dynamically create aliases for quick access to these servers from bash. I wrote... (4 Replies)
Discussion started by: jelloir
4 Replies

6. Shell Programming and Scripting

Finish script help

I am trying to add a finish script that can copy hosts, static routes and a few other files into relevant directories on a client system. These files would be mounted as nfs resource on the client as hosts.hostname, static_route.hostname etc. Script will compare the hostname of the client and copy... (0 Replies)
Discussion started by: c0kazaz
0 Replies

7. Shell Programming and Scripting

Execute unix shell script to text file using the script

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)
Discussion started by: mastercar
4 Replies

8. UNIX for Dummies Questions & Answers

Jumpstart finish script (Solaris 10)

Hi there, I wanted to write a finish script for my jumpstart server which creates a ntp.conf file and enables ntp on the client machines during installation. Is that possible? Thanks for the help :) P.S. I'm a real Solaris noob, so do excuse me if I sound like an idiot..lol (1 Reply)
Discussion started by: iman453
1 Replies

9. Shell Programming and Scripting

How to check succeesfull finish of a executable from the sheel script

Hi, I want to know is there a way out wherein we can know that the C++ executable has finished its task. Following is the steps: 1.Shell script calls a executable after setting all the env variables. 2.Now after the executable has done its job(basically to create some outpur files).The... (2 Replies)
Discussion started by: electroon
2 Replies

10. Shell Programming and Scripting

How do i execute script in the current shell

How do i run a shell script or perl script with in the context of a current shell. I know that i can use command source. but we can't pass any arguments to our script if we use source command as it takes only one argement i.e filename Is there any way to run a script in the current shell... (5 Replies)
Discussion started by: Naresh Kumar
5 Replies
Login or Register to Ask a Question