Solved

run a file under Linux

Posted on 2009-03-31
9
276 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
High Bandwidth Usage 6 93
error log using ftp 7 75
Run Secure WMI query from CentOS 5 130
RHEL 6.7 Gnome Desktop on VMware 6 VM 9 107
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

685 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