Difference in Executing a Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Difference in Executing a Script
# 1  
Old 07-26-2006
CPU & Memory Difference in Executing a Script

Can anyone tell me the difference between the following
execution ways:

1) . ./filename

2) ./filename

Also when to use the either.
# 2  
Old 07-26-2006
Vangalli

./filname means execute the file from current directory


../filename means execute file from parent directory


Regards,
Vangalli
# 3  
Old 07-26-2006
How about this

. filename and how does it differ from ./filename
# 4  
Old 07-26-2006
:))

no dear............

./ is used to execute the files which dont have global execution permission.......... once u add this file to /usr/bin and shnage the permission to executable .... it wont work................
# 5  
Old 07-26-2006
pretty confused

I have created a file abc .The file permissions are -rw-r--r-- .
Now when i execute using
./abc ---> it gives cannot execute

But if i execute using . ./abc OR . abc
It executes

Could you please elaborate on this.
# 6  
Old 07-26-2006
"./file" means execute the file located in the current directory. "./" is a realtive path where "." means "actual directory".
". ./file" does not exactly execute the file, it's like an "import" of its contents, so, if inside the file there are exports or shell commands, they will be executed.
Regards.
# 7  
Old 07-26-2006
Quote:
Originally Posted by Shivdatta
pretty confused

I have created a file abc .The file permissions are -rw-r--r-- .
Now when i execute using
./abc ---> it gives cannot execute

But if i execute using . ./abc OR . abc
It executes

Could you please elaborate on this.
That's correct, to execute the file like "./abc" you need to give it execution permissions, for instance: "rwxr-xr-x"

". abc" works bacause you have "." in your PATH, which is not a good idea... Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing Oracle script from UNIX Script

Hi, I am new to UNIX and want to execute oracle script from unix script. I have written below script but i am getting below error. #!/bin/bash file="/home/usr/control/control_file1" while read line do #$line=@$line #echo $line sqlplus tiger/scott@DB @$line exit #echo "$line" done... (3 Replies)
Discussion started by: vipin kumar rai
3 Replies

2. Shell Programming and Scripting

Difference in executing the script

Hi Team, a silly question. Let's say i have a script called xyz.ksh what is the difference in executing the script as follows? ./xyz.ksh ksh xyz.ksh Thanks (2 Replies)
Discussion started by: kmanivan82
2 Replies

3. UNIX for Dummies Questions & Answers

Script dosent exits after executing the script

Hi i wrote a script which dosent exists after executing any help #!/bin/bash netstat -ptlen | grep 10000 if ; then echo "Hive Thrift server is running" exit 0 else echo "Hive Thrift server is down Trying to Bring up the service" | mail -s "ALERT" team@domain.com `nohup hive... (7 Replies)
Discussion started by: vikatakavi
7 Replies

4. UNIX for Dummies Questions & Answers

Difference Between executing llike ./myscript.ksh and . ./myscript.ksh

Hi , What is the diffence between executing the script like ./myscript.ksh . ./myscript.ksh I have found 2 difference but could not find the reason 1. If i export a variable in myscript.ksh and execute it like . ./myscript.ksh the i can access the other scripts that are present in... (5 Replies)
Discussion started by: max_hammer
5 Replies

5. Shell Programming and Scripting

Use of ./ in executing a script.

Hi Guys, Hope you are doing well out there. Can you please let me know why do we use "./" to run a shell script? Is it to run the script in the current shell or something else? What if I have already defined a bang in the script say #!/bin/ksh and then running the script as... (2 Replies)
Discussion started by: singh.chandan18
2 Replies

6. Shell Programming and Scripting

Variables of executed script available in executing script

Hi, I have a script get_DB_var.ksh which do a data base call and get some variables as below: sqlplus -silent $user/$pass@dbname <<END select col1, col2, col3 from table_name where col4=$1; exit; END Now I want to access all these variables i.e.... (9 Replies)
Discussion started by: dips_ag
9 Replies

7. Shell Programming and Scripting

What is the difference executing a script with . in the front versus not putting a "."

Hi All, I know this has been discussed a lot but still I need some more answers. I am running this is ksh on AIX 5.3 I believe putting a "." in front of the script will start a new shell, is that correct?? I have a script which override some PATH variables and it does not do that... (3 Replies)
Discussion started by: Hangman2
3 Replies

8. UNIX for Advanced & Expert Users

Executing a shell script from windows;script present in unix

I need to execute a shell script kept in unix machine from windows. User id, password area available. For eg. There's a shell script wich moves all the logs kept in my home directory to a directory named LOGS. Now i need to get this done through windows; either using a batch file, or java... (4 Replies)
Discussion started by: rajneesh_kapoor
4 Replies

9. Shell Programming and Scripting

script not executing

Hi , Kindly advice whats wrong with this script. It is not executing. ...# #!/bin/ksh find. -name "b.log" if ; then echo "1" fi ...# Thanks (5 Replies)
Discussion started by: himvat
5 Replies

10. UNIX for Dummies Questions & Answers

Difference between executing a shell using sh and .

Is there any difference in executing the shell using sh and . and ./. I had a shell script and i observed that anyone is ale to execute the script eith sh even without having the execute permission.how is so? (2 Replies)
Discussion started by: soumyo_das
2 Replies
Login or Register to Ask a Question