file execution confusion


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers file execution confusion
# 8  
Old 02-08-2012
Firstly the script will execute as sh ./filename BUT because the script executes in a sub-shell a subsequent echo $APT_ORCHHOME will not show the new value of the environement variable.
When executed as . ./filename the script executes in the current environment and you can see the change. This is the same way your profile works.

Had to look really carefully to find out how you managed to execute this script at all. Because you are not the owner of the script and you are not in the same group as the script you can only read the script because it has read permissions for "other". Normally a shared script would have permissions 755 (but yours has 754).
Because there are no execute permissions for "other" that is why it failed to execute as ./filename.
When you tried to execute the script as just filename that failed to find the file because the directory is not in $PATH. However even if the directory was in $PATH it would still fail because there is no execute permissions for "other".

So! When you precede the command with either a real "sh" (sh filename) or are already running "sh" (. ./filename) you cannot automatically start a shell to execute a script file unless your account has execute permissions for that script file.

Last edited by methyl; 02-08-2012 at 09:32 AM..
# 9  
Old 02-08-2012
hi , can you please help
# 10  
Old 02-08-2012
Amongst my reply, the only bit that matters is:

Quote:
When executed as . ./filename the script executes in the current environment and you can see the change. This is the same way your profile works.
The rest of the issues with executing the script are due to the permissions of the file or due to fact that the directory containing the script is not in $PATH. This is actually irrelevant as . ./filename is the only sensible way to execute the script if you want the environment variable to be set in the current environment. In some modern Bourne-like Shells you may find the "source" command which has the same effect but it is not a standard command and is not valid in "ksh".
# 11  
Old 02-10-2012
lemme guess... you don't own the file. you aren't in the group.
therefore, you do not have execute permission on this file.

Code:
sh ./file_name

... should work.
# 12  
Old 02-11-2012
hi , i really see i have a long way to go in unix regarding forking , subshell and those kind of stuff , can someone tell me where i can get the information regarding all this , as a beginner where would it be good to start

---------- Post updated at 01:29 AM ---------- Previous update was at 12:53 AM ----------

Code:
anumit01@ldoh0010isphn01:/opt/IBM/dev/APP/InformationServer/Server/DSEngine> id dsadm
uid=8293(dsadm) gid=2281(dstage) groups=2281(dstage),10009(IA),1006(db2ctrl),2283(dsadm1),6550(iauser),5000(loadl),3344(mft),2001(mqm),668(sshallow),1001(hrtrans),10002(etldev),1000041(hrdw-dev),1002000(hrt)
anumit01@ldoh0010isphn01:/opt/IBM/dev/APP/InformationServer/Server/DSEngine> id anumit01
uid=1000401(anumit01) gid=1000000(u-users) groups=1000000(u-users),1000151(etldeploy),10002(etldev),1000143(etltestdeploy)

also the owner of the file which i am trying to execute and my user id sshare a same group , does that not mean i belong to that group , so that i can execute the files

Last edited by methyl; 02-12-2012 at 07:07 PM.. Reason: please use code tags.
# 13  
Old 02-12-2012
Quote:
also the owner of the file which i am trying to execute and my user id sshare a same group , does that not mean i belong to that group , so that i can execute the files
Please re-phrase the question in common English. I really don't understand the question.


My understanding of the question (might be wrong):
If you can read the script file, you can execute the script file with sh ./scriptname. In order to execute the script automatically just by typing the name of the script your username must be in a group which has execute permissions for that script.
# 14  
Old 02-19-2012
id dsadm
Code:
uid=8293(dsadm) gid=2281(dstage) groups=2281(dstage),10009(IA),1006(db2ctrl),2283(dsadm1),6550(iauser),5000(loadl),3344(mft),2001(mqm),668(sshallow),1001(hrtrans),10002(etldev),1000041(hrdw-dev),1002000(hrt)

here there is a group 10002(etldev).this is the list of groups to which the owner of the script belong

now my id shows
Code:
gid=1000000(u-users) groups=1000000(u-users),1000151(etldeploy),10002(etldev),1000143(etltestdeploy)

so me and owner of the script share a common goroup and file is executable for group , so i should be able to execute it this way (./scriptname ) right ? but i am not able to execute without sh . please help me

Last edited by Scott; 02-19-2012 at 05:26 AM.. Reason: Please use code tags
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execution of loop :Splitting a single file into multiple .dat file

hdr=$(cut -c1 $path$file|head -1)#extract header”H” trl=$(cut -c|path$file|tail -1)#extract trailer “T” SplitFile=$(cut -c 50-250 $path 1$newfile |sed'$/ *$//' head -1')# to trim white space and extract table name If; then # start loop if it is a header While read I #read file Do... (4 Replies)
Discussion started by: SwagatikaP1
4 Replies

2. UNIX for Dummies Questions & Answers

File System and Storage Array Confusion

Hi Friends, I have a host(Suse Linux 10.4) which has 2 luns presented from 2 different arrays HP eva and xp. we are planning to migrate hp eva to 3par. When i look for physical volume i see /dev/dm-4, /dev/dm-5, /dev/dm-7and when i look for multipath -ll i see dm-8,dm-9,dm-7. So i can't confirm... (6 Replies)
Discussion started by: munna529
6 Replies

3. Shell Programming and Scripting

check file exist before execution

Hi , I have a scripts which run at every 1 min and do some job. this scripts look for the file in the directory and move in the other directory. I want to write a line which forst check if the *.LOG file exist in the directory if *.LOG exist then do for i in *.LOG load ... (7 Replies)
Discussion started by: guddu_12
7 Replies

4. UNIX for Dummies Questions & Answers

Remote file execution

Hello, I'm new to scripting so, sorry if this is a dumb question. What's the best way to execute a .sh file remotely? I want to log into server "b" from server "a" & run a script. "./scriptname.sh". At this point, all I'm looking to do is a simple ls -la > output.txt within the script to capture... (3 Replies)
Discussion started by: crunch10c
3 Replies

5. Shell Programming and Scripting

Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test. The expect script is run... (2 Replies)
Discussion started by: twk
2 Replies

6. Shell Programming and Scripting

File execution problem

hi all currently we are building lot of new servers(50+).What im looking for is a small piece of code that should help me in running a script that will configure company specific software in all the new boxes.For that currently we have to login to each and every new box manuallly and run that... (2 Replies)
Discussion started by: coolkid
2 Replies

7. Shell Programming and Scripting

file ownership confusion

Hello all, I have a script that runs on both the test and production box. The script is owned by a user (abcd for example) with permission set to 700. When this script is run as a root, the log file generated has owner and group as abcdowner and abcdgroup respectively. Now, when I run the same... (4 Replies)
Discussion started by: solaix14
4 Replies

8. UNIX for Dummies Questions & Answers

Execution bit for a file

Hi Given read and write permission ( for group others etc) on any ordinary text file one can edit and view the file . In this case what role does an execution field play. (4 Replies)
Discussion started by: ss250041
4 Replies

9. UNIX for Dummies Questions & Answers

confusion (file pointer and file descripter)

Hi everybody, i am newbie to unix and confused with file pointers and file descripters. could anyone help me to clear my doubts .. when we call unix system calls to create a file then we are dealing wih file descripters i think file descripters are also normals file as stored inhard disks... (1 Reply)
Discussion started by: johnray31
1 Replies

10. UNIX for Advanced & Expert Users

File system Confusion

Hello All, I administer my department server and now Im assigned the job of installing a new server. The old server has no home directory but the user accounts are managed using a script and they are partitioned in /fs/grad, /fs/ugrad, /fs/fac, /fs/alumni. But when I finger for a... (1 Reply)
Discussion started by: maybemedic
1 Replies
Login or Register to Ask a Question