fuser: difference with bin/sh and bin/ksh shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers fuser: difference with bin/sh and bin/ksh shell script
# 1  
Old 05-29-2009
fuser: difference with bin/sh and bin/ksh shell script

Hi,

I have a problem I don't understand with fuser.

I launch a simple shell script mysleep.sh:
Quote:
#!/bin/sh
sleep 10
I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted:
mysleep:


Then I modify my script switching from #!/bin/sh to #!/bin/ksh
Quote:
#!/bin/ksh
sleep 10
I launch the command fuser -fu mysleep.sh and this time I have the information:
mysleep: 24721o(myuser)

Why fuser doesn't find my process file when I use #!/bin/sh ?


Thanks
# 2  
Old 05-29-2009
What OS? With Solaris 8, the /bin/sh version shows the file open during execution.

But I guess that some version of sh on some system might realize that it had read the entire file and decided to close it prior to running it. There is no standard that I can think of that requires sh to keep the file open. I would not be very surprised by behavior like that.
# 3  
Old 05-29-2009
It's a Solaris: SunOS 5.10 Generic_127111-03

Thanks for the information.
# 4  
Old 05-29-2009
I too am surprised.
If you want to find the PID.

Code:
PID=$$
echo "PID=${PID}"

# 5  
Old 05-29-2009
Quote:
Originally Posted by methyl
I too am surprised.
If you want to find the PID.

Code:
PID=$$
echo "PID=${PID}"

Thanks, but I'm searching for open process from a specific location and I've tried with fuser but as you can see it doesn't work well.

Out of topic, I've also tried with pwdx on this computer but it's doesn't work well too.

I launch my shell script mysleep.sh from /usr/u/myuser/myscripts/:
Quote:
#!/bin/sh
/usr/u/myuser/myothertest.sh
I launch the command pwdx with the PID of myothertest.sh and it returns /usr/u/myuser/myscripts/ instead of the expected /usr/u/myuser/
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Usage of #!/bin/sh vs #!/bin/bash shell scripts?

Some question about the usage of shell scripts: 1.) Are the commands of the base shell scripts a subset of bash commands? 2.) Assume I got a long, long script WITHOUT the first line. How can I find out if the script was originally designed für "sh" or "bash"? 3.) How can I check a given... (3 Replies)
Discussion started by: pstein
3 Replies

2. AIX

Redistribution bin required for AIX. j7r164redist.7.1.0.25.bin

Hi, I am planning to install a version of Informatica on my AIX box. It requires a specific java build in pap6470_27sr2-20141101_01(SR2). The current link for IBM 64-bit SDK for AIX®, JavaTM Technology Edition, Version 7 Release 1 has a more recent version in j7r164redist.7.1.0.75.bin. Is... (4 Replies)
Discussion started by: meetpraveens
4 Replies

3. Solaris

What is the difference between xpg4/bin and usr/bin?

Hi Experts, I found that the same commands(sort, du, df, find, grep etc.) exists in both dir. What is the difference to use them? i.e: to use xpg4/bin/grep and usr/bin/grep My OS version is SunOS 5.10 Regards, Saps (7 Replies)
Discussion started by: saps19
7 Replies

4. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

5. UNIX for Dummies Questions & Answers

Difference between "/bin/bash" & "/bin/sh"

what if the difference between #!/bin/sh and #!/bin/bash I wrote a script with the second heading now when i change my heading to the first one ...the script is not executing well....im not getting the required output....any solution to this problem...or do i have to start the... (3 Replies)
Discussion started by: xerox
3 Replies

6. Shell Programming and Scripting

/bin/sh and /bin/ksh problem

we have a shell script that we are using in KSH if ]; then _IFS=$IFS IFS=: and it's failing on /bin/sh . Is there a simple way to modify it to work on both . ( not with awk) Thanks in adv (3 Replies)
Discussion started by: talashil
3 Replies

7. Shell Programming and Scripting

#!/bin/sh and #!/bin/ksh

Hi All, I have a shell (#!/bin/sh) with below piece of code: if ! then echo Staging table ABC_INT_TAB is not present in the schema >> $OUTPUT fi Shell is throwning below error and continue to work even after this error... (3 Replies)
Discussion started by: bhush782003
3 Replies

8. UNIX for Dummies Questions & Answers

Difference between /bin, /usr/bin, /sbin ?

Hi All, Can somebody tell me the difference between /bin, /usr/bin, /sbin ? Thanx in advance, Saneesh Joseph (3 Replies)
Discussion started by: saneeshjose
3 Replies

9. Shell Programming and Scripting

#!/usr/bin/ksh Command Interpreter in a sh script

Hi, I have a developer that is trying to start a script with sh "scriptname". In the script, he is specifying #!/usr/bin/ksh as the command interpreter. For some reason sh is ignoring the #!/usr/bin/ksh. We are running Solaris 8. Does anyone have any ideas what could be causing this? Here... (3 Replies)
Discussion started by: ckeith79
3 Replies

10. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies
Login or Register to Ask a Question