LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-01-2007, 02:49 PM   #1
sirius56
Member
 
Registered: Nov 2006
Location: Illinois
Distribution: Ubuntu 10.4
Posts: 35

Rep: Reputation: 15
Running a Script


Suppose I wrote a simple script, xyz, and it is in my home directory.

In order to run the script, I would type
./xyz
and the script executes.

Why do I need the slash? Why not just

.xyz ?

or

./home/user/xyz ?

The latter two forms do not work.

Does the . (dot) represent "run" or "current directory"? If current directory, then why do I need the / (slash) if I am already in my home directory?


Thank you for any clarification.
 
Old 01-01-2007, 02:54 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
./ represents the current directory.

. by itself would make it a hidden file (the period would be part
of the filename).

The second form doesn't work because you don't have (most likely
you don't) home/user/xyz as a directory structure under your home.



Cheers,
Tink
 
Old 01-01-2007, 03:00 PM   #3
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie stretch
Posts: 1,592

Rep: Reputation: 97
Hi,

'.' means current directory or "./" means current directory.
'.xyz" is a file name which begins with '.' and is hidden. (ls -a can display hidden files)

If ./xyz in your home works, /home/yourname/xyz also works (the latter is "absolute path'), when ~/ is /home/yourname. (you cannot have '.' before '/')
xyz works when you have your current directory in shell variable "path", (I assume you use shell tcsh, ksh, zsh, bash... depending on your setting.)

Happy Penguins!
 
Old 01-02-2007, 01:55 PM   #4
whk
Member
 
Registered: Jun 2005
Posts: 202

Rep: Reputation: 35
Also take a look at permissions
$ chmod 755 xyz
$ xyz
for example
./ again specifies the path
have fun
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a script with another user brazilian_user Linux - General 8 10-18-2006 10:24 PM
running a .sh script bungle3 Linux - Software 3 10-03-2006 09:59 AM
Running a script spacemonk Linux - Newbie 4 07-30-2004 05:02 AM
Running a script file johnlb Linux - Newbie 2 02-19-2003 03:17 AM
c/c++ running a shell script? thermalpants Programming 3 05-12-2002 12:41 PM


All times are GMT -5. The time now is 04:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration