1835260 Members
2432 Online
110078 Solutions
New Discussion

vi confusing?

 
SOLVED
Go to solution
leereg_5
Frequent Advisor

vi confusing?

Hi gurus:
I edit a script with vi plus the option -x, how to make it excuteable?


Thanks in advance!
Always UNIX!
8 REPLIES 8
Mark van Hassel
Respected Contributor

Re: vi confusing?

Hi,

Just use the chmod command, for example: chmod -x [file name] will make it executable for the owner, group and others.
chmod 700 [file name] will make it readable, writable and executable for the owner.
see "man chmod"
The surest sign that life exists elsewhere in the universe is that none of it has tried to contact us
Vincenzo Restuccia
Honored Contributor

Re: vi confusing?

Mark is right,otherwise you can to execute your script with:
#sh ./script
Andreas D. Skjervold
Honored Contributor

Re: vi confusing?

Hi
chmod 755 <script>
makes the script readable and executable for owner,group and others as well as writable for owner.

Andreas
Only by ignoring what everyone think is important, can you be aware of what everyone ignores!
Shahul
Esteemed Contributor

Re: vi confusing?

Hi

After completing the edit job, save and come out. Then use this

#chmod 755 script . Now owner, group, and others will executable permission.

#chmod 744 script Here only owner will have execute permission.

U can try this alos

#sh ./script

Best of luck

Shahul
leereg_5
Frequent Advisor

Re: vi confusing?

$vi -x to.sh
Key:
"to.sh" [New file]
$chmod +x to.sh
$./to.sh
./to.sh: syntax error at line 2 : `newline or ;' unexpected
while I do as follow:
$vi to.sh
$chmod +x to.sh
$./to.sh
It is OK now!
Why?
Always UNIX!
Frank Li
Trusted Contributor
Solution

Re: vi confusing?

Hi,

You can make it execute but it cann't be executed correctly since it is encripted !
"vi -x txt" is used to encript a text/document , not used to edit a script.
Hi Friend
Steve Post
Trusted Contributor

Re: vi confusing?

Sorry if this obvious to you. ...but.

vi doesn't change permisions on files (like to make it executable). Like they said here, that's "chmod". vi edits files.


Brad Reeves
New Member

Re: vi confusing?


If you are using a vim or some other vi clone -x encrypts the file. A quick way to continue editing and to change the execute status is to do a :w file.sh then a :!chmod +x file.sh
You can execute from within the editor the same way :!./file.sh
Assuming that the first line of the script is #!/bin/sh etc..