Solved

run a file under Linux

Posted on 2009-03-31
9
272 Views
Last Modified: 2013-12-16
Hi All,

I tried to run a file but without any success.
File name: cim_matbuch_neu.sh
Location: /usr2/stamm/start_app

I enter this: ./su -user_nsd -c "/usr2/stamm/start_app/cim_matbuch_neu.sh"
and received the error message ./su not found

My colleague told me to enter: su - user_nsd -c "/usr2/stamm/start_app/cim_matbuch_neu.sh "

He said that it will work that way but I don't understand how can it work without ./ (dot slash)?

I didn't try it because I won't mess up things here in the company.

Thanks,



0
Comment
Question by:didier20
  • 3
  • 3
  • 3
9 Comments
 
LVL 14

Expert Comment

by:Deepak Kosaraju
ID: 24027462
su is a command to switch user, and su - is used to give full root access control of the user which u r using after - option
so su [space] - [space]  -c
space i type above dosen't imply u need to type it but u need to use spacbar.
More on su command look hit man pages by command
man su
su - user_nsd -c "/usr2/stamm/start_app/cim_matbuch_neu.sh"

Open in new window

0
 
LVL 23

Expert Comment

by:Maciej S
ID: 24027477
./su means run su from current (./) directory.
While su is located in directory which is for sure in PATH directory, you may run it without specification directory (just "su").
If you want to specify directory, it should be something like this: /bin/su (or wherever your su is located - you may check this with "which su" command).
In linux/unix you have to specify full/relative path to binary/script unless such binary/script is located in directory which is specified in PATH variable (run "echo $PATH" to see what directories you have in your PATH variable).
0
 

Author Comment

by:didier20
ID: 24028115
You say that this is OK:
su - user_nsd -c "/usr2/stamm/start_app/cim_matbuch_neu.sh"

I know that this is OK as well:
./folap
(dot slash folap)

But how do I know, if somebody tells me, run a file whether I should use ./ (dot slash) or not?
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 24028189
You can use ./file only when file is in your current directory.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 14

Expert Comment

by:Deepak Kosaraju
ID: 24028512
Added to oklit you can use ./ only when the file is in current directory and has execute permissions
0
 

Author Comment

by:didier20
ID: 24028592
You mean in MY current directory not in THE directory I am currently ?

If I am in the directory /usr2/home/my username, I can use ./
If I am in the directory /usr2/home, I can't use ./
Is that right?
0
 
LVL 14

Accepted Solution

by:
Deepak Kosaraju earned 50 total points
ID: 24028722
No! where ever you are if u r using su then u have call su either directly as su if u r path variables are set to /bin, else you have use /bin/su -  -c .
0
 

Author Comment

by:didier20
ID: 24029933
there's a file in /usr2/home/my username called folap. If I am in "my username" I can run the file folap with ./folap
If I change to /usr2/home and want to run the file with
su - my username -c /usr2/home/my username/folap
then the system ask me first for my password but afterwards I get the error message:

Xlib: connection to "localhost:0.0" refused by server
Xlib: Client is not authorized to connect to Server

I use the correct password.

0
 
LVL 23

Assisted Solution

by:Maciej S
Maciej S earned 50 total points
ID: 24030358
It's different problem. It means, that your X servers doesn't want to talk to you :)
First, run (as user, not root) "xhost +" command.
Then, run your folap application.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now