|
-
December 6th, 2003, 02:33 PM
#1
Junior Member
exploiting root
Ok. So I have my computer sitting next to mine. It's a standard RedHat 9 box with standard installs set. I set up an account for me to log onto with minimal access. I do however have access to a vi editor. So I type in my source code. How do I save/run this code as a command? In other words my question is so simple most books don't have it. How do I save my script and run it? This question I realise isn't very hard, but I cant find the answer.
-
December 6th, 2003, 02:39 PM
#2
Ensure that the file has appropriate permissions (i.e.., execute). Depending on whether it's a c program or a shell script you'll do either:
./scriptname
OR
gcc filename.c -o filename
./filename
-
December 6th, 2003, 03:16 PM
#3
Member
i reccomend using something like pico, nano, or joe as a simple text editor. VI is not exactly user friendly. i think to quit wtih saving its something like :q!
-
December 6th, 2003, 03:27 PM
#4
:q! is to save and overread existing permissions (usually used by root)
In vi to
- save to file you do :w
- save and exit you do :wq
- save, exit and override permissions :wq! (usually root)
Check out this tutorial on using vi. I'd actually recommend getting used to using it because of the power and the fact that you can always find it on any *nix distribution (AFAIK)
-
December 6th, 2003, 03:46 PM
#5
Senior Member
I would also suggest Nano or something. VI takes some getting used to. Like wassup said it is not the most friendly editor there is. Actually Red Hat 9 comes with pico.
pico filename.txt
-
December 6th, 2003, 04:23 PM
#6
Find some command lists for VI. It is an incredibly powerful text editor if you know what you are doing. Google for commands..
-Cheers-
PS: http://www.chem.brown.edu/instructions/vi.html
-
December 6th, 2003, 04:24 PM
#7
Junior Member
So. I open vi. I type vi script10112 for example. I use regular scripting not C or anything of the sort. Then I do esc to get back into vi command mode. Do I just type wq, press enter and then it's saved to the appropriate area. Since I do #!/bin/bash in the very beginning, it should be ready to be executed right? So I exit and save, then i type script10112 to execute? Or do I need to chmod it to executable? Thanks for putting up with me guys!
-
December 6th, 2003, 05:59 PM
#8
yes, you do have to chmod (to like 755) to make it executable
-
December 6th, 2003, 07:05 PM
#9
Do unto others as you would have them do unto you.
The international ban against torturing prisoners of war does not necessarily apply to suspects detained in America\'s war on terror, Attorney General John Ashcroft told a Senate oversight committee
-- true colors revealed, a brown shirt and jackboots
-
December 6th, 2003, 07:16 PM
#10
Junior Member
So...let's recap:
(Type) vi [filename]
(To edit file - press) i
(To stop editting) ESC
(To Save and quit) :wq!
(In the shell, give permissions) chmod 755 [filename]
(Assuming you had !/bin/bash, run) ./[filename]
(If not) bash [filename]
There are 10 kinds of people in this world: those who understand binary, and those who don\'t.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|