Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

run a file under Linux

Posted on 2009-03-31
9
Medium Priority
?
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 150 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 150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
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 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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

636 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