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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

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

    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:

    [CODE=UNIX]
    #!/bin/sh
    #sample shell using the if
    echo "Let's create a fancy directory"
    if [ -d unixbackup ]
    then
    echo "directory unixbackup exists"
    else
    echo "Looks like directory unixbackup does not exist"
    echo "Would you like to create it now? (y/n)"
    read x
    echo $x
    if [ $x = "y" ]
    then
    mkdir unixbackup
    echo "Super! unixbackup directory has been created"
    else
    echo "Sorry! unixbackup directory has not been created"
    fi
    fi
    [/CODE]

    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
    Last edited by Dököll; Feb 17 '08, 03:11 AM. Reason: text...
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by Dököll
    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:

    [CODE=UNIX]
    #!/bin/sh
    #sample shell using the if
    echo "Let's create a fancy directory"
    if [ -d unixbackup ]
    then
    echo "directory unixbackup exists"
    else
    echo "Looks like directory unixbackup does not exist"
    echo "Would you like to create it now? (y/n)"
    read x
    echo $x
    if [ $x = "y" ]
    then
    mkdir unixbackup
    echo "Super! unixbackup directory has been created"
    else
    echo "Sorry! unixbackup directory has not been created"
    fi
    fi
    [/CODE]

    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

    Comment

    • Dököll
      Recognized Expert Top Contributor
      • Nov 2006
      • 2379

      #3
      Originally posted by numberwhun
      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

      Comment

      • Dököll
        Recognized Expert Top Contributor
        • Nov 2006
        • 2379

        #4
        Originally posted by Dököll
        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!

        Comment

        • Dököll
          Recognized Expert Top Contributor
          • Nov 2006
          • 2379

          #5
          Originally posted by Dö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!
          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:

          Code:
          #!/bin/sh
          #Sample Shell to remove directory...
          
          echo "Let's delete a fancy directory"
          if [ -d unixbackup ]
          then
                  echo "directory unixbackup exists"
                  echo "Would you like to delete it now? (y/n)"
                  read x
                  echo $x
                  if [ $x = "y" ]
                  then
                        rmdir  unixbackup
                          echo "Super! unixbackup directory has been deleted"
                  else
                          echo "Sorry! unixbackup directory has not been deleted"
                  fi
          fi
          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!

          Comment

          • Dököll
            Recognized Expert Top Contributor
            • Nov 2006
            • 2379

            #6
            Originally posted by Dököll
            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:

            Code:
            #!/bin/sh
            #Sample Shell to remove directory...
            
            echo "Let's delete a fancy directory"
            if [ -d unixbackup ]
            then
                    echo "directory unixbackup exists"
                    echo "Would you like to delete it now? (y/n)"
                    read x
                    echo $x
                    if [ $x = "y" ]
                    then
                          rmdir  unixbackup
                            echo "Super! unixbackup directory has been deleted"
                    else
                            echo "Sorry! unixbackup directory has not been deleted"
                    fi
            fi
            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:-)

            Comment

            Working...