Solved

run a file under Linux

Posted on 2009-03-31
9
274 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 23

Expert Comment

by:Maciej S
ID: 24028189
You can use ./file only when file is in your current directory.
0
 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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" …
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.:

770 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