Name of subscript


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Name of subscript
# 1  
Old 12-23-2011
Name of subscript

I have a script that executes another, so script1 executes script2.

Using the $0 variable inside script2 returns the name of script1.

How can I get the name of script2?

Thanks
# 2  
Old 12-23-2011
Weird. It is working properly when I tried it:
Code:
[root@linux ~]# cat a.sh
#!/bin/bash
./b.sh
[root@linux ~]# cat b.sh
#!/bin/bash
echo $0
[root@linux ~]# ./a.sh
./b.sh

Can you post how are you calling script2? And how are you using $0 inside script2?
# 3  
Old 12-23-2011
Mystery solved!

I need to realize the difference between: ./b.sh and . b.sh

Completely different results. Thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Calling subscript with sh vs. ksh

I ran into an issue today that I was able to resolve, but I don't quite understand why the resolution worked. I'm wondering if anyone can help me make sense of it. I have a "kicker" script that calls 4 subscripts on a RHEL 6.9 server. It calls the scripts in sequence checking for a 0 exit code... (5 Replies)
Discussion started by: derndingle
5 Replies

2. Shell Programming and Scripting

How to use a subscript and a super script while printing a character

I want to print a output after executing a awk command How to represent a subscript or a superscript while using print command eg : Ts. where character 's' is subscript of T T2 where '2' is the superscript of T thank you. Shashi: (3 Replies)
Discussion started by: shashi792
3 Replies

3. Shell Programming and Scripting

How to solve Subscript out of range?

Hi everyone I want to compare numbers line by line Example array = 12 15 15 19 14 I have code: #!bin/csh set a = 1 set b = 2 while($a<6) if($array == $array)then echo "EQUAL" else if($array < $array)then echo "SMALLER" else echo "BIGGER" endif @ a = $a + 1 @ b = $b + 1 (2 Replies)
Discussion started by: vincyoxy
2 Replies

4. UNIX for Dummies Questions & Answers

creating a subscript which checks for a flag?

I want to incorportae a subscript in a job script which is used for loading purposes. What i require is that before a job runs it should check for a flag ,if flag is not present then create it and the loading should start. Once loading finishes it should delete the flag. So if any other load... (3 Replies)
Discussion started by: bathla
3 Replies

5. Shell Programming and Scripting

checking for a flag in a subscript?

I want to incorportae a subscript in a job script which is used for loading purposes. What i require is that before a job runs it should check for a flag ,if flag is not present then create it and the loading should start. Once loading finishes it should delete the flag. So if any other load... (2 Replies)
Discussion started by: bathla
2 Replies

6. AIX

Checking for flag in a subscript?

I want to incorportae a subscript in a job script which is used for loading purposes. What i require is that before a job runs it should check for a flag ,if flag is not present then create it and the loading should start. Once loading finishes it should delete the flag. So if any other load... (1 Reply)
Discussion started by: bathla
1 Replies

7. Shell Programming and Scripting

Perl hashes "Can't use subscript on private hash"

This is driving me mad, where am I going wrong? The relevant segment of code: sub getndsybcons { my @servers=@{$_}; my @sybservers=@{$_}; my %results; foreach my $server(@servers) { my $biggestsyb; my $biggestsybval=0; ... (9 Replies)
Discussion started by: Smiling Dragon
9 Replies

8. Shell Programming and Scripting

Calling subscript but sleep halts the main script

Ok, I have written a main script which checks a directory contents every 30 secs then sleeps. The subscript does a usermod, if the user is logged on, it sleeps for 30 secs and then trys again over and over again. Here's the problem. when the subscript is called ./subscript.sh or exec... (1 Reply)
Discussion started by: doublejz
1 Replies
Login or Register to Ask a Question