Как установить Ubuntu с pxe с запуском для установки дополнительных программ

Вот некоторая информация с несколькими командами, которые могут помочь, посмотрите http://ss64.com/bash/syntax-permissions.html

find . -type f -print0 | xargs -0 chmod 775 # change all file permissions in current directory

find . -type d -print0 | xargs -0 chmod 755 # change directory permissions

Вы можете использовать следующий сценарий заголовка. Поместите mkscript.sh в свой $PATH. Выполните mkscript.sh из рабочего каталога, где хранятся скрипты python. Сценарий создает полезную информацию заголовка, записывает сценарий и делает его исполняемым, а затем открывает выбранный редактор; в вашем случае VIM.

Я модифицировал mkscript.sh, он будет создавать скрипты с расширением python *.py

Вызывается переменная ${PYTHON_VERSION}, поэтому PYTHON_VERSION="/usr/bin/python --version" добавлена ​​в /etc/environment ] файл. Посмотрите на http://ss64.com/bash/syntax-permissions.html

#!/bin/bash -       
#title           :mkscript.sh
#description     :This script will make a header for a PYTHON script.
#author      :bgw
#date            :20111101
#version         :0.4    
#usage       :bash mkscript.sh
#notes           :Install Vim and Emacs to use this script.
#bash_version    :4.1.5(1)-release
#==============================================================================

today=$(date +%Y%m%d)
div=======================================

/usr/bin/clear

_select_title(){

    # Get the user input.
    printf "Enter a title: " ; read -r title

    # Remove the spaces from the title if necessary.
    title=${title// /_}

    # Convert uppercase to lowercase.
    title=${title,,}

    # Add .sh to the end of the title if it is not there already.
    [ "${title: -3}" != '.py' ] && title=${title}.py

    # Check to see if the file exists already.
    if [ -e $title ] ; then 
        printf "\n%s\n%s\n\n" "The script \"$title\" already exists." \
        "Please select another title."
        _select_title
    fi

}

_select_title

printf "Enter a description: " ; read -r dscrpt
printf "Enter your name: " ; read -r name
printf "Enter the version number: " ; read -r vnum

# Format the output and write it to a file.
printf "%-16s\n\
%-16s%-8s\n\
%-16s%-8s\n\
%-16s%-8s\n\
%-16s%-8s\n\
%-16s%-8s\n\
%-16s%-8s\n\
%-16s%-8s\n\
%-16s%-8s\n\
%s\n\n\n" '#!/usr/bin/python -' '#title' ":$title" '#description' \
":${dscrpt}" '#author' ":$name" '#date' ":$today" '#version' \
":$vnum" '#usage' ":./$title" '#notes' ':' '#python_version' \
":${PYTHON_VERSION}" \#$div${div} > $title

# Make the file executable.
chmod +x $title

/usr/bin/clear

_select_editor(){

    # Select between Vim or Emacs.
    printf "%s\n%s\n%s\n\n" "Select an editor." "1 for Vim." "2 for Emacs."
    read -r editor

    # Open the file with the cursor on the twelth line.
    case $editor in
        1) vim +12 $title
            ;;
        2) emacs +12 $title &
            ;;
        *) /usr/bin/clear
           printf "%s\n%s\n\n" "I did not understand your selection." \
               "Press  to quit."
           _select_editor
            ;;
    esac

}

_select_editor

131
задан 14 July 2017 в 13:35

0 ответов

Другие вопросы по тегам:

Похожие вопросы: