Solved

run a file under Linux

Posted on 2009-03-31
9
278 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
Industry Leaders: 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!

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.
Suggested Courses

737 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