By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,571 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,571 IT Pros & Developers. It's quick & easy.

vi editor eating away at my chars, namely #! in UNIX

Dököll
Expert 100+
P: 2,364
Not sure how to post this, I'll just come out with it gang...

I ran into some trouble loading certain commands using an editor called "pico editor". All was working fine and suddenly stopped responding to my commands which I'll post in a bit; which contained the characters mentioned above...

So I thought okay I'll try another editor, lo and behold, I cannot run the code there either because this editor does not like me adding #!/bin/sh, and has deleted these chars rendering the code virtually unusable.

Is there a command I need to add in order for the vi editor to accept #! in the code. pico is not working and I have since driven to the college just case it was my network, same treatement there:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh                 
  2. #sample shell using the if                                                                            
  3. echo "Let's create a fancy directory"                                          
  4. if [ -d unixbackup ]
  5. then
  6.         echo "directory unixbackup exists"
  7. else
  8.         echo "Looks like directory unixbackup does not exist"
  9.         echo "Would you like to create it now? (y/n)"
  10.         read x
  11.         echo $x
  12.         if [ $x = "y" ]
  13.         then
  14.                 mkdir unixbackup
  15.                 echo "Super! unixbackup directory has been created"
  16.         else
  17.                 echo "Sorry! unixbackup directory has not been created"
  18.         fi
  19. fi
  20.  
It's nothing fancy but if I could run it through the vi editor, it would be great.
What are your thoughts?

Thanks!

Dököll
Feb 17 '08 #1
Share this Question
Share on Google+
5 Replies

numberwhun
Expert Mod 2.5K+
P: 3,503
Not sure how to post this, I'll just come out with it gang...

I ran into some trouble loading certain commands using an editor called "pico editor". All was working fine and suddenly stopped responding to my commands which I'll post in a bit; which contained the characters mentioned above...

So I thought okay I'll try another editor, lo and behold, I cannot run the code there either because this editor does not like me adding #!/bin/sh, and has deleted these chars rendering the code virtually unusable.

Is there a command I need to add in order for the vi editor to accept #! in the code. pico is not working and I have since driven to the college just case it was my network, same treatement there:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh                 
  2. #sample shell using the if                                                                            
  3. echo "Let's create a fancy directory"                                          
  4. if [ -d unixbackup ]
  5. then
  6.         echo "directory unixbackup exists"
  7. else
  8.         echo "Looks like directory unixbackup does not exist"
  9.         echo "Would you like to create it now? (y/n)"
  10.         read x
  11.         echo $x
  12.         if [ $x = "y" ]
  13.         then
  14.                 mkdir unixbackup
  15.                 echo "Super! unixbackup directory has been created"
  16.         else
  17.                 echo "Sorry! unixbackup directory has not been created"
  18.         fi
  19. fi
  20.  
It's nothing fancy but if I could run it through the vi editor, it would be great.
What are your thoughts?

Thanks!

Dököll
I code in vi when using *nix all the time and have never had any issue where it removed text without me removing it. Just save the file after adding the text. Have you tried adding the text in vi and see if it happens. I don't see why a text editor would care what text you put into it. Unless it was placed in its command interface. In vi, if you hit escape -> : that puts you into command mode and if you enter something after the colon, then it would be interpreted as a command and not text.

Regards,

Jeff
Feb 17 '08 #2

Dököll
Expert 100+
P: 2,364
I code in vi when using *nix all the time and have never had any issue where it removed text without me removing it. Just save the file after adding the text. Have you tried adding the text in vi and see if it happens. I don't see why a text editor would care what text you put into it. Unless it was placed in its command interface. In vi, if you hit escape -> : that puts you into command mode and if you enter something after the colon, then it would be interpreted as a command and not text.

Regards,

Jeff
Hey Jeff, good advice!

I don't think I saved after adding the code there. Perhaps I was disoriented since pico runs a bit differently.

Will give it a whirl again, thanks Jeff!

Köll
Feb 17 '08 #3

Dököll
Expert 100+
P: 2,364
Hey Jeff, good advice!

I don't think I saved after adding the code there. Perhaps I was disoriented since pico runs a bit differently.

Will give it a whirl again, thanks Jeff!

Köll
By the way, Jeff...

Why would I get a "terminal too wide" type of an error? Now and then when I have a lot of code in the editor it seems to throw that message down below.

In a bit!
Feb 17 '08 #4

Dököll
Expert 100+
P: 2,364
By the way, Jeff...

Why would I get a "terminal too wide" type of an error? Now and then when I have a lot of code in the editor it seems to throw that message down below.

In a bit!
Please disregard the above. Looks like vi does not like the screen maximized. That's news to me.

The command now works and as mentioned vi does not delete stuff, my silly way of looking at it failed me:-)

Will be using vi more often to grab some tips.

The problem I am having now is that, I cannot remove my directory:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh
  2. #Sample Shell to remove directory...
  3.  
  4. echo "Let's delete a fancy directory"
  5. if [ -d unixbackup ]
  6. then
  7.         echo "directory unixbackup exists"
  8.         echo "Would you like to delete it now? (y/n)"
  9.         read x
  10.         echo $x
  11.         if [ $x = "y" ]
  12.         then
  13.               rmdir  unixbackup
  14.                 echo "Super! unixbackup directory has been deleted"
  15.         else
  16.                 echo "Sorry! unixbackup directory has not been deleted"
  17.         fi
  18. fi
  19.  
After giving myself full access to a script file containing above command through SSH Secure Shell, I get a Command not found. It was working before.

I attempted to back track, just to see if I had done something like delete the script by accident, still nothing.

What do you think may be happening?

Thanks for your help!
Feb 17 '08 #5

Dököll
Expert 100+
P: 2,364
Please disregard the above. Looks like vi does not like the screen maximized. That's news to me.

The command now works and as mentioned vi does not delete stuff, my silly way of looking at it failed me:-)

Will be using vi more often to grab some tips.

The problem I am having now is that, I cannot remove my directory:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh
  2. #Sample Shell to remove directory...
  3.  
  4. echo "Let's delete a fancy directory"
  5. if [ -d unixbackup ]
  6. then
  7.         echo "directory unixbackup exists"
  8.         echo "Would you like to delete it now? (y/n)"
  9.         read x
  10.         echo $x
  11.         if [ $x = "y" ]
  12.         then
  13.               rmdir  unixbackup
  14.                 echo "Super! unixbackup directory has been deleted"
  15.         else
  16.                 echo "Sorry! unixbackup directory has not been deleted"
  17.         fi
  18. fi
  19.  
After giving myself full access to a script file containing above command through SSH Secure Shell, I get a Command not found. It was working before.

I attempted to back track, just to see if I had done something like delete the script by accident, still nothing.

What do you think may be happening?

Thanks for your help!
About this problem!

Well, I must be losing my marbles but I deleted my .cshrc and .longin files after making copies of them.

All is well now:-)
Feb 22 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.