<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Shell script to edit a file using 'vi' in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824831#M940530</link>
    <description>How do I write a shell script that allow the user to edit a file using vi?&lt;BR /&gt;Let's say the script is called viScript. The usage should be viScript [filename].&lt;BR /&gt;&lt;BR /&gt;Before using vi to edit the file, it creates a backup copy first.&lt;BR /&gt;&lt;BR /&gt;The script must accept one or no parameter from the command line. If no parameter is entered, then prompt the user to enter one. If none is entered then exit. If more than one is entered then display a usage message and exit.&lt;BR /&gt;&lt;BR /&gt;When a filename is entered, it must check whether the file exists and has either read-only or read/write permission for the file. An error message appears if the file does not exist or if the user does not have read-only or read/write permission.&lt;BR /&gt;&lt;BR /&gt;If the user has read-only access to the file, a message is displayed to that effect and along with the file contents. This means that the user can display the file only but not edit it.&lt;BR /&gt;&lt;BR /&gt;If the user has read/write access, a copy of the file is made as filename.bak and then call vi to edit the file.&lt;BR /&gt;</description>
    <pubDate>Mon, 14 Oct 2002 03:36:54 GMT</pubDate>
    <dc:creator>cybermilky</dc:creator>
    <dc:date>2002-10-14T03:36:54Z</dc:date>
    <item>
      <title>Shell script to edit a file using 'vi'</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824831#M940530</link>
      <description>How do I write a shell script that allow the user to edit a file using vi?&lt;BR /&gt;Let's say the script is called viScript. The usage should be viScript [filename].&lt;BR /&gt;&lt;BR /&gt;Before using vi to edit the file, it creates a backup copy first.&lt;BR /&gt;&lt;BR /&gt;The script must accept one or no parameter from the command line. If no parameter is entered, then prompt the user to enter one. If none is entered then exit. If more than one is entered then display a usage message and exit.&lt;BR /&gt;&lt;BR /&gt;When a filename is entered, it must check whether the file exists and has either read-only or read/write permission for the file. An error message appears if the file does not exist or if the user does not have read-only or read/write permission.&lt;BR /&gt;&lt;BR /&gt;If the user has read-only access to the file, a message is displayed to that effect and along with the file contents. This means that the user can display the file only but not edit it.&lt;BR /&gt;&lt;BR /&gt;If the user has read/write access, a copy of the file is made as filename.bak and then call vi to edit the file.&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Oct 2002 03:36:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824831#M940530</guid>
      <dc:creator>cybermilky</dc:creator>
      <dc:date>2002-10-14T03:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to edit a file using 'vi'</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824832#M940531</link>
      <description>If your using CDE, then it has own text editor based on 'vi'&lt;BR /&gt;&lt;BR /&gt;Alternatively have a look at the HP Porting Centre. There are a number of editing tools, 'EMACS' could be one that your after.&lt;BR /&gt;&lt;BR /&gt;Go to this link and use 'editor' without the quotes in the search.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.connect.org.uk/" target="_blank"&gt;http://hpux.connect.org.uk/&lt;/A&gt;</description>
      <pubDate>Mon, 14 Oct 2002 04:19:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824832#M940531</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2002-10-14T04:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to edit a file using 'vi'</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824833#M940532</link>
      <description>The script must accept one or no parameter from the command line. If no parameter is entered, then prompt the user to enter one. If none is entered then exit. If more than one is entered then display a usage message and exit.&lt;BR /&gt;---&lt;BR /&gt;if [ $# -eq 0 ]; then&lt;BR /&gt;   echo "Please insert filename \c" &lt;BR /&gt;   read infile&lt;BR /&gt;else&lt;BR /&gt;  infile=$1&lt;BR /&gt;fi&lt;BR /&gt;---&lt;BR /&gt;Before using vi to edit the file, it creates a backup copy first.&lt;BR /&gt;---&lt;BR /&gt;cp $infile $infile.$USER,`date`&lt;BR /&gt;---&lt;BR /&gt;When a filename is entered, it must check whether the file exists and has either read-only or read/write permission for the file. An error message appears if the file does not exist or if the user does not have read-only or read/write permission.&lt;BR /&gt;---&lt;BR /&gt;vi&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;If the user has read-only access to the file, a message is displayed to that effect and along with the file contents. This means that the user can display the file only but not edit it.&lt;BR /&gt;---&lt;BR /&gt;vi&lt;BR /&gt;---&lt;BR /&gt;If the user has read/write access, a copy of the file is made as filename.bak and then call vi to edit the file. &lt;BR /&gt;---&lt;BR /&gt;see above&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;vi does the most things you want to do&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Mon, 14 Oct 2002 04:42:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824833#M940532</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2002-10-14T04:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to edit a file using 'vi'</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824834#M940533</link>
      <description>Hi,&lt;BR /&gt;if what you need this script is just for taking backups before editing this file, try using emacs.&lt;BR /&gt;&lt;BR /&gt;Other wise, a script could be like this.&lt;BR /&gt;&lt;BR /&gt;[test conditions]&lt;BR /&gt;[backup file]&lt;BR /&gt;vi $filename&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and when the user types :q in vi, the script terminates automatically.&lt;BR /&gt;hth&lt;BR /&gt;-balaji</description>
      <pubDate>Mon, 14 Oct 2002 05:42:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824834#M940533</guid>
      <dc:creator>Balaji N</dc:creator>
      <dc:date>2002-10-14T05:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to edit a file using 'vi'</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824835#M940534</link>
      <description>You may want to keep in mind that this can be a security issue.  The user can shell out of vi and do anything they have permission to do.  &lt;BR /&gt;&lt;BR /&gt;Just my 2 cents worth...&lt;BR /&gt;&lt;BR /&gt;Mark</description>
      <pubDate>Tue, 15 Oct 2002 13:28:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-to-edit-a-file-using-vi/m-p/2824835#M940534</guid>
      <dc:creator>Mark Ellzey</dc:creator>
      <dc:date>2002-10-15T13:28:03Z</dc:date>
    </item>
  </channel>
</rss>

