head: „sh/DownloadUpdates.sh“ kann nicht zum Lesen ...

head: „sh/DownloadUpdates.sh“ kann nicht zum Lesen ...

Postby offliner » 13.11.2014, 08:22

(For a wider audience, I'm using English, even though my system uses German locale as you can see)
Using wsusoffline942.zip on Linux, started from the top directory as "bash sh/DownloadUpdates.sh":
---
Download Service Packs? [y/n] n
Download .Net framework? [y/n] y
Download Microsoft Security Essentials files? [y/n] y
Download Microsoft Windows Defender definition files? [y/n] y
Please specify your proxy (default: none, http://[username:password@]<server>:<port>])
Create ISO-Image after download? [y/n] y

head: „sh/DownloadUpdates.sh“ kann nicht zum Lesen geöffnet werden: Datei oder Verzeichnis nicht gefunden
Your choice
System: w61-x64
Language: deu
Parameter: /makeiso /dotnet /excludesp /msse /wddefs
Proxy: none

Do you want to download now? [y/n] y
---
Obviously printheader() only works if the directory did not change since the command was started, or if an absolute path was used to start the script...
offliner
 

Re: head: „sh/DownloadUpdates.sh“ kann nicht zum Lesen ...

Postby itovikws » 24.11.2014, 13:23

Change into the sh folder and run bash DownloadUpdates.sh from there.

- Peder
itovikws
 

Re: head: „sh/DownloadUpdates.sh“ kann nicht zum Lesen ...

Postby hbuhrmester » 04.12.2014, 16:38

So, let's try to sort this out:

The case switch in lines 44 - 60 of DownloadUpdates.sh, version 9.5:
Code: Select all
case "$OpSys" in
    Linux)
    #set working directory
    cd $( dirname $(readlink -f "$0") )
    ;;
    *BSD|Darwin)
    echo "Operating System $OpSys not yet supported"
    echo "Maybe something doesn't work as expected"
    sleep 10
    #set working directory
    cd $( dirname $(readlink "$0") )
    ;;
    *)
    echo "unknown Operating System"
    exit 1
    ;;
esac


can be replaced with all of this:
Code: Select all
# Setting up the working directory:
#
# $0 is the script name, as it was typed on the command line;
# this may be an absolute or relative path name,
# and it may include symbolic links.
#
# $canonical_name is the real path name of the script.
#
# $prog_name is the file name of the script.
#
# $dir_name is the name of the enclosing directory.
#
# Explicitly evaluating these variables step-by-step
# will also help, should the path ever contain spaces.

case "$OpSys" in
    Linux)
        #set working directory
        canonical_name=$(readlink -f "$0")
        prog_name=$(basename "$canonical_name")
        dir_name=$(dirname "$canonical_name")
        cd "$dir_name"
        ;;
    *BSD|Darwin)
        echo "Operating System $OpSys not yet supported"
        echo "Maybe something doesn't work as expected"
        sleep 10
        #set working directory
        canonical_name=$(readlink "$0")
        prog_name=$(basename "$canonical_name")
        dir_name=$(dirname "$canonical_name")
        cd "$dir_name"
        ;;
    *)
        echo "unknown Operating System"
        exit 1
        ;;
esac

# Printing all variables for debugging:
if [ $debug -eq 1 ]; then
    echo "script name:       " "$0"
    echo "canonical name:    " "$canonical_name"
    echo "file name:         " "$prog_name"
    echo "directory name:    " "$dir_name"
    echo "working directory: " "$(pwd)"
fi


The shell function printheader() in lines 315 - 318 of DownloadUpdates.sh:
Code: Select all
printheader() {
echo " "
head -20 "$0" | grep '^###'
}


can be replaced with this definition:
Code: Select all
printheader() {
    echo " "
    head -20 "$canonical_name" | grep '^###'
}


I hope this helps,
Hartmut
hbuhrmester
 
Posts: 525
Joined: 11.10.2013, 20:59


Return to Linux

Who is online

Users browsing this forum: No registered users and 4 guests