Cannot run script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cannot run script
# 1  
Old 01-18-2012
Cannot run script

hi , i had a script , say script name , user and group had privilege to execute it . but my account does not belong to the group , so wen i ran the script ./scriptname , i got an error no privilege , but wen i use . ./scriptname it runs fine , how is this possibleSmilie
# 2  
Old 01-18-2012
hi... check if a script with the same name is present in the parent directory and that you have permissions on that script.

Code:
./scriptname

will try to execute the script in the current directory.

Code:
../scriptname

will try to execute the script in the parent directory.

so if you have permissions on the script in parent directory it will be executed.

Regards,
A!
This User Gave Thanks to archimedes For This Post:
# 3  
Old 01-18-2012
Quote:
Originally Posted by archimedes
hi... check if a script with the same name is present in the parent directory and that you have permissions on that script.
Good catch!
Note : here parent directory referred by archimedes is the parent directory of the current directory. Don't mistake parent directory for home directory!

Code:
root@bt> pwd
/root/aen/tmp
root@bt> ls run
-rwxr-xr-x 1 root root 22 Jan 18 10:01 run*
root@bt> cd test
root@bt> pwd
/root/aen/tmp/test
root@bt> ls run
---------- 1 root root 22 Jan 18 10:56 run
root@bt> ../run
I got executed!

--ahamed
# 4  
Old 01-18-2012
i did this


MITHUN> ls dsjob
dsjob
MITHUN> cd ..
MITHUN> ls dsjob
/bin/ls: dsjob: No such file or directory


i cannot find such a file in parent directory
# 5  
Old 01-18-2012
hi,

so sorry.. i mistook
Code:
. ./scriptname

for
Code:
../scriptname

Failed to see the " " in between

can you please run this cmd and paste the output:

Code:
 
ls -ltr scriptname

maybe because your account doesnt belong to the group, you donot have executable permissions on it. so . ./scriptname works as it is an explicit cmd.

Regards,
A!
# 6  
Old 01-18-2012
You probably have r(read) rights to the file, but not e(x)ecutable rights. Therefore you can read the script but not execute it. To keep scripts from being executed by users both r and x rights need to be removed. The dot is sourcing the file that contains the script. i.e. it is reading the file and executing the script in your current interactive shell, instead of a separate shell.

This should also work
Code:
/bin/sh ./scriptname

or whatever shell the script is supposed to be run with and it executes the script in a separate shell.
# 7  
Old 01-18-2012
hi ,

I tried /bin/sh ./scriptname and it didnt work , this file sets environmental variable it seems ,
ls -ltr gives
-rwxr-xr-- 1 dsadm dstage 8841 2011-09-19 11:49 scriptname

when i try this . ./scriptname i can see new values are added to path . but sh scriptname or ./scriptname or /bin/sh ./scriptname does not set the new values to path Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

3. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

4. Shell Programming and Scripting

Run SQL thru shell script: how to get a new line when run sql query?

Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database. I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :( What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies

5. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

6. Shell Programming and Scripting

Make script that run with argument if not run from configuration file argument

Hello, Is there any method thorugh which script can take argument if pass otherwise if argument doesn't pass then it takes the argument from the configuration file i.e I am workiing on a script which will run through crontab and the script will chekout the code ,zip and copy to the... (3 Replies)
Discussion started by: rohit22hamirpur
3 Replies

7. AIX

My script didn't run every run every minute at cronjob

In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * script.sh When I run it manually, I can run it. Is that anything wrong with the above line? If I change it to something like below,... (4 Replies)
Discussion started by: ngaisteve1
4 Replies

8. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

9. UNIX for Advanced & Expert Users

script to run different shells which run different processes

Hi, Would like to ask the experts if anyone knows how to run a script like this: dtterm -title shell1 run process1 on shell1 dtterm -title shell2 run process2 on shell2 cheers! p/s: sorry if i used the wrong forum, quite concussed after watching world cup for several nights; but I... (2 Replies)
Discussion started by: mochi
2 Replies
Login or Register to Ask a Question