<?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 Re: How to make scripts executable automatically? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592890#M375076</link>
    <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;As I understand your question, you can't, not directly.  The permissions (modes) of a file are set at the file's 'open()' by supplying an octal 'mode'.  For files, this mode is generally, 0666 as set by the shell (and most programs).  For directories, a mode of 0777 is used.&lt;BR /&gt;&lt;BR /&gt;Thus, any file created by the shell is going to have derive its permissions from 0666 "and-ed" with the process's umask.  Thus, even with a 'umask' of 000, your file will still not have execute permissions.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 02 Mar 2010 01:26:18 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2010-03-02T01:26:18Z</dc:date>
    <item>
      <title>How to make scripts executable automatically?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592888#M375074</link>
      <description>&lt;BR /&gt;I want to make any scripts that I create executable by default, how can I achieve that?&lt;BR /&gt;&lt;BR /&gt;By scripts I mean .sh, .bash &amp;amp; .pl.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.</description>
      <pubDate>Tue, 02 Mar 2010 00:42:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592888#M375074</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2010-03-02T00:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to make scripts executable automatically?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592889#M375075</link>
      <description>To be "executable" in Unix, a script should have three things:&lt;BR /&gt;&lt;BR /&gt;a) it should have a valid interpreter specified in the first line, e.g. "#!/bin/sh", "#!/usr/bin/perl" or whatever.&lt;BR /&gt;&lt;BR /&gt;b) it should be placed in a directory that is listed in your PATH&lt;BR /&gt;&lt;BR /&gt;(You can add the current directory "." to your path if you really want; but if you feel you must do it, please place it as the _last_ element in your PATH. Don't do it at all if you are root, or the next entry in some "Unix sysadmin horror stories" thread might be yours.)&lt;BR /&gt;&lt;BR /&gt;c) it should have the execute permission bit set: chmod a+x &lt;NAME-OF-SCRIPT&gt;&lt;/NAME-OF-SCRIPT&gt;&lt;BR /&gt;I guess your problem is most likely c).&lt;BR /&gt;&lt;BR /&gt;Create a script, shell function or alias that will do two things: &lt;BR /&gt;1.) invoke your favorite editor to create/edit your script(s), &lt;BR /&gt;2.) after the editor process ends, runs chmod a+x on the same file.&lt;BR /&gt;&lt;BR /&gt;Use this script to edit and create scripts instead of your regular editor command.&lt;BR /&gt;&lt;BR /&gt;For a trivial example:&lt;BR /&gt;&lt;BR /&gt;---begin script "/usr/local/bin/es"---&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;${EDITOR:-vi} "$@"&lt;BR /&gt;chmod a+x "$@"&lt;BR /&gt;---end script---&lt;BR /&gt;&lt;BR /&gt;es = Edit Script.&lt;BR /&gt;Set the environment variable EDITOR to your favorite editor. If the variable is not set, "vi" is used, as is the common convention in Unix systems.&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;es somescript.sh&lt;BR /&gt;&lt;BR /&gt;If you use a "programmable" editor (like Emacs for example), it might even be possible to make the editor detect when you're writing a script and automatically set the execute permission on the script.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Tue, 02 Mar 2010 01:10:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592889#M375075</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2010-03-02T01:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to make scripts executable automatically?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592890#M375076</link>
      <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;As I understand your question, you can't, not directly.  The permissions (modes) of a file are set at the file's 'open()' by supplying an octal 'mode'.  For files, this mode is generally, 0666 as set by the shell (and most programs).  For directories, a mode of 0777 is used.&lt;BR /&gt;&lt;BR /&gt;Thus, any file created by the shell is going to have derive its permissions from 0666 "and-ed" with the process's umask.  Thus, even with a 'umask' of 000, your file will still not have execute permissions.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 02 Mar 2010 01:26:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592890#M375076</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-03-02T01:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to make scripts executable automatically?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592891#M375077</link>
      <description>Thanks MK... &lt;BR /&gt;&lt;BR /&gt;one small thing , can you explain "${EDITOR:-vi}" ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan,</description>
      <pubDate>Tue, 02 Mar 2010 01:34:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592891#M375077</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2010-03-02T01:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to make scripts executable automatically?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592892#M375078</link>
      <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; one small thing , can you explain "${EDITOR:-vi}" ?&lt;BR /&gt;&lt;BR /&gt;See your friendly manpages for 'sh-posix':&lt;BR /&gt;&lt;BR /&gt;${parameter:-word}&lt;BR /&gt;&lt;BR /&gt;If parameter is set and is nonnull, substitute its value; otherwise, substitute word.&lt;BR /&gt;&lt;BR /&gt;Thus, set your EDITOR to 'vi' unless its already set to something else.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 02 Mar 2010 01:39:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592892#M375078</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-03-02T01:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to make scripts executable automatically?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592893#M375079</link>
      <description>&amp;gt;I want to make any scripts that I create executable by default?&lt;BR /&gt;&lt;BR /&gt;Why would you want that?  How would vi tell if it is a script?&lt;BR /&gt;&lt;BR /&gt;You can always use chmod after you use vi.  Or you can use:&lt;BR /&gt;:!chmod a+x %&lt;BR /&gt;after you write the file.</description>
      <pubDate>Tue, 02 Mar 2010 08:51:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592893#M375079</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-03-02T08:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to make scripts executable automatically?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592894#M375080</link>
      <description>&lt;!--!*#--&gt;Hi Allan,&lt;BR /&gt;&lt;BR /&gt;There is a better way to do, what you are looking for, if you are using vi editor.&lt;BR /&gt;&lt;BR /&gt;You can make use of 'autocmd' of vi.&lt;BR /&gt;&lt;BR /&gt;Say, if you are going to create an expect script, with .exp extension, you need to follow the following steps.&lt;BR /&gt;&lt;BR /&gt;1. Add a file say, ~/exp_header.txt&lt;BR /&gt;2. Add following lines in ~/exp_header.txt&lt;BR /&gt;:insert&lt;BR /&gt;#!/usr/bin/expect -f&lt;BR /&gt;[You can add additional header, e.g., Author, Date, Description etc. here]&lt;BR /&gt;3. Add following lines in your ~/.exrc file,&lt;BR /&gt;autocmd bufnewfile *.exp so ~/exp_header.txt&lt;BR /&gt;autocmd BufwritePost *.exp execute "!chmod +x " .expand("%")&lt;BR /&gt;&lt;BR /&gt;So, whenever you are creating a new .exp file, vi will add "#!/usr/bin/expect -f" on the first line of the file. And when you are saving the file vi will change the file mode to executable.&lt;BR /&gt;&lt;BR /&gt;Now you can use ./abc.exp&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pradosh&lt;BR /&gt;</description>
      <pubDate>Tue, 18 May 2010 11:48:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592894#M375080</guid>
      <dc:creator>Pradosh_1</dc:creator>
      <dc:date>2010-05-18T11:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to make scripts executable automatically?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592895#M375081</link>
      <description>&amp;gt;Pradosh: You can make use of autocmd of vi.&lt;BR /&gt;&lt;BR /&gt;This is for vim, not vi.</description>
      <pubDate>Sat, 22 May 2010 15:11:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-make-scripts-executable-automatically/m-p/4592895#M375081</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-05-22T15:11:37Z</dc:date>
    </item>
  </channel>
</rss>

