LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Mint 18.3 cannot find shell script (https://www.linuxquestions.org/questions/linux-newbie-8/mint-18-3-cannot-find-shell-script-4175623347/)

weinelb 02-08-2018 11:37 AM

Mint 18.3 cannot find shell script
 
I have a Canon "install" shell script which I am unable to run. Have used "chmod" to make it executable—confirmed by fact that "open" shows up the run, view, run in terminal popup. When I select Run in Terminal it says "No such file or directory". It makes no difference if I "cd" to the folder containing script or if I try to run it from Terminal by entering full path and file name. It is in a subdirectory of my Desktop folder and that folder name contains no spaces.

Any suggestions?

rtmistler 02-08-2018 11:56 AM

There may be several possible explanations or issues.

The script may be running, but be calling another command which can't be found and therefore this is the source of the complaint.

Your descriptions of verifying and running seem to be a mix of File Manager, or Desktop Shortcut forms as well as terminal entry.

Can you post the output of "ls -l" of the directory where the script is, and indicate what filename the script is.

Can you try to run it from within that directory, but show the exact output. It should indicate what command it is saying is the "No such file or directory"

weinelb 02-08-2018 12:50 PM

1 Attachment(s)
rtmistler,

I am definitely in the correct directory and the script is there, but a picture probably shows it best:

rtmistler 02-08-2018 12:55 PM

First you didn't type it correctly, you mistyped the name as intall.sh.

Next you mistyped how to run it.

When in that sub-directory, just run it as follows:
Code:

./install.sh

weinelb 02-08-2018 01:37 PM

1 Attachment(s)
rtmistler,

First, check the "ls" the name was not mistyped. Second, I had previously tried it with the "this directory" prefix and that had zero effect. See this capture:

BW-userx 02-08-2018 01:44 PM

that last photo, last message in that last photo, says hangup as if it tried to do something. what caused it to return a 'hangup' and not command not found, or file not there, message?

it might be due to something within that script that it is not finding.

how did you get inside of a deb tar? deb's are compressed install tars.

rtmistler 02-08-2018 01:51 PM

Well it was mistyped the first time, before you tried a sudo command modifier.

Still looking for the output of "ls -l" for the directory containing that script.

It seems to be complaining of /bin/bash, and perhaps you do not have /bin/bash on your system, an "ls -l /bin/bash" output would be helpful to see.

Can you post the first few lines of that install.sh script as well?

scasey 02-08-2018 02:02 PM

The No such file or directory is (probably) caused by the #!/bin/bash line being terminated by a ^M
The file apparently contains Windows line ends (CRLF)
Try this:
Backup the script
Convert the line ends
Run the converted script
Code:

cp -p install.sh install.sh.orig
dos2unix install.sh.orig > install.sh
./install.sh

[also please do what rmistler requested...my guess is just that, a guess...seeing the ls -l and the contents of the script will definitely help]

Let us know what happens

hydrurga 02-08-2018 02:09 PM

This may be of use (series of posts from this post onwards):

https://www.linuxquestions.org/quest...ml#post5805778

weinelb 02-08-2018 02:20 PM

1 Attachment(s)
rtmistler,

The directory content is visible in the first attachment, showing "install.sh" is definitely there and the run, view, run in Terminal pop up shows it is executable. However, here are the "ls"s and "run" you wanted (and, yes, user nancyn is member of adm):

rtmistler 02-08-2018 02:29 PM

I agree with scasey that there may be a problem with the #!/bin/bash line.

However you have not done the additional things requested. Please double check those requests from my last post, #7.

Just to be clear:
Quote:

Originally Posted by rtmistler (Post 5817430)
Well it was mistyped the first time, before you tried a sudo command modifier.

Still looking for the output of "ls -l" for the directory containing that script.

It seems to be complaining of /bin/bash, and perhaps you do not have /bin/bash on your system, an "ls -l /bin/bash" output would be helpful to see.

Can you post the first few lines of that install.sh script as well?


BW-userx 02-08-2018 02:34 PM

that and I'd definitely open up that install.sh script and take a look at what is going on inside of it.

dash or bash?

weinelb 02-08-2018 02:59 PM

scasey,

That almost got it. Shell script was in DOS/Windows format (courtesy of Canon). However, running it resulted in these errors:
Code:

==================================================

Canon Inkjet Printer Driver
Version 5.40
Copyright CANON INC. 2001-2016

==================================================
Command executed = sudo dpkg -iG ./packages/cnijfilter2_5.40-1_amd64.deb
dpkg-deb: file looks like it might be an archive which has been
 corrupted by being downloaded in ASCII mode

dpkg-deb: error: './packages/cnijfilter2_5.40-1_amd64.deb' is not a debian format archive
dpkg: error processing archive ./packages/cnijfilter2_5.40-1_amd64.deb (--install):
 subprocess dpkg-deb --control returned error exit status 2
Errors were encountered while processing:
 ./packages/cnijfilter2_5.40-1_amd64.deb
Command executed = sudo dpkg -P cnijfilter2
dpkg: warning: ignoring request to remove cnijfilter2 which isn't installed

It appears Canon built the script under Windows; since it was downloaded in Linux, unpacked with "tar" under Linux and target system on their web page was debian linux. Damn! I'll have to try again...

weinelb 02-08-2018 03:08 PM

scasey & business kid,

Here is the shell script (as much as will fit):
Code:

#!/bin/bash

##############################################################################
##
##  Canon Inkjet Printer Driver for Linux
##  Copyright CANON INC. 2001-2016
##
##  This program is free software; you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation; version 2 of the License.
##
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with this program; if not, write to the Free Software
##  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
##
##############################################################################

C_version="5.40-1"
C_copyright_end="2016"
C_default_system="deb"

P_support_printer=("MB2100" "MB2700" "IB4100" "MB5100" "MB5400" "TS9000" "TS8000" "TS6000" "TS5000" "MG3000" "E470" "G4000")

L_INST_COM_01_01="Command executed = %s\n"

L_INST_COM_01_02="An error occurred. The package management system cannot be identified.\n"
L_INST_COM_01_03="An error occurred. A necessary package could not be found in the proper location.\n"
L_INST_COM_01_04="Installation has been completed.\n"
L_INST_COM_01_05="An error occurred. Your environment cannot be identified as 32-bit or 64-bit.\nTry to install again by using the following command.\n"
L_INST_COM_01_06="An error occurred. The specified environment differs from your environment.\nTry to install again by using the following command.\n"

L_INST_COM_02_01="Usage: %s\n"

L_INST_COM_02_02="Uninstallation has been completed.\n"

L_INST_COM_03_01="[Package]\n"


L_INST_PRN_00_01="Canon Inkjet Printer Driver"
L_INST_PRN_00_02="Version %s"
L_INST_PRN_00_03="Copyright CANON INC. %s-%s"

L_INST_PRN_01_01="Register Printer\n"
L_INST_PRN_01_02="Next, register the printer to the computer.\n"
L_INST_PRN_01_03="Connect the printer, and then turn on the power.\nTo use the printer on the network, connect the printer to the network.\nWhen the printer is ready, press the Enter key.\n"

L_INST_PRN_01_04="Connection Method\n"
L_INST_PRN_01_05="USB\n"
L_INST_PRN_01_06="Network\n"
L_INST_PRN_01_07="Select the connection method.%s"

L_INST_PRN_01_08="Searching for printers...\n"

L_INST_PRN_01_09="Select Printer\n"
L_INST_PRN_01_10="Select the printer.\nIf the printer you want to use is not listed, select Update [0] to search again.\nTo cancel the process, enter [Q].\n"
L_INST_PRN_01_11="Update"
L_INST_PRN_01_12="Target printers detected (MAC address  IP address)\n"
L_INST_PRN_01_13="Other printers detected (MAC address  IP address)\n"
L_INST_PRN_01_14="Target printers detected\n"
L_INST_PRN_01_15="Other printers detected\n"
L_INST_PRN_01_16="Currently selected:%s %s\n"

L_INST_PRN_01_17="Enter the value."
L_INST_PRN_01_18="Could not detect the target printer.\n"

L_INST_PRN_01_19="Register Printer\n"
L_INST_PRN_01_20="Enter the printer name.%s"

L_INST_PRN_01_21="The printer name you entered already exists. Do you want to overwrite it?\nEnter [y] for Yes or [n] for No.%s"

L_INST_PRN_01_22="The printer name is invalid.\nYou can only use the following characters for the printer name:\n alphanumeric characters (a-z, A-Z, 0-9), \".\", \"-\", \"_\", \"+\", \"@\"\n"

L_INST_PRN_01_23="Set as Default Printer\n"
L_INST_PRN_01_24="Do you want to set this printer as the default printer?\nEnter [y] for Yes or [n] for No.%s"

L_INST_PRN_01_25="Printer Name : %s\n"

L_INST_PRN_01_26="Select this printer name for printing.\n"
L_INST_PRN_01_27="The printer registration has not been completed.\nRegister the printer manually by using the lpadmin command.\n"

L_INST_PRN_02_01="Uninstall Printer\n"
L_INST_PRN_02_02="All printer registration for this model will be deleted.\n"
L_INST_PRN_02_03="Do you want to continue?\nEnter [y] for Yes or [n] for No.%s"

L_INST_PRN_02_04="Failed to delete [%s].\nAfter the uninstall process is finished, delete this printer manually by using the lpadmin command.\n"
L_INST_PRN_02_05="Failed to delete printers.\nAfter the uninstall process is finished, delete these printers manually by using the lpadmin command.\n"


C_main_module="cnijfilter2"
C_copyright_start="2001"
C_ppdfile_path="/usr/share/cups/model/*"
raster_command="rastertocanonij"

# internalversion : 3.20.01.005

#################################################################
#### C_function name define
#################################################################
C_function01="P_FUNC_MAIN_make_queue"
C_function02="P_FUNC_MAIN_delete_all_queue"
C_function03="P_FUNC_show_copyright"

#################################################################
#### path, filename, commandname, etc.
#################################################################
P_entry_list_path=""
P_all_entry_list_path=""
P_entry_list_path_rpm="/usr/local/share/"
P_entry_list_path_deb="/usr/share/"
P_entry_list_dir="cnijfilter2/"
P_all_entry_list_dir="cnijfilter*/"
P_entry_list_name="cnij_entry"
P_cupsd_command_1="/etc/init.d/cups"
P_cupsd_command_2="/etc/init.d/cupsys"
P_cupsd_command_current=""
P_lpadmin_command_full="/usr/sbin/lpadmin"
P_lpadmin_command_current=""
P_is_std_usb_backend=0
P_ppd_install_path="/usr/share/cups/model/"

#################################################################
#### Show the copyright  $1:version
#################################################################
P_FUNC_show_copyright()
{
#        p_copyright1="Canon Inkjet Printer Driver Ver."$1" for Linux"
#        p_copyright2="Copyright CANON INC. 2001-2011"

#        echo $p_copyright1; echo $p_copyright2; echo $p_copyright3

        printf "$L_INST_PRN_00_01\n"
        printf "$L_INST_PRN_00_02\n" "$1"
        printf "$L_INST_PRN_00_03\n" "$C_copyright_start" "$C_copyright_end"
}

#################################################################
#### Add registered entry name to entry_list_file. $1:entry_list_file name  $2:entry name to add
#################################################################
p_FUNC_write_entrydata_to_file()
{
        local p_local_existentrys=""

        p_local_existentrys=`cat $P_entry_list_fullname`

        #to Upper case
        p_local_name_to_write=`echo "$2" | tr a-z A-Z`
       
       
        # set delimiter
        IFS='
        '
        #-----------------------------
        # Check entry list file (If same name exists, you should not to add entry name)
        #-----------------------------
        for line in ${p_local_existentrys}; do
                if [ -n "$line" ]; then
                        #to Upper case
                        line=`echo "$line" | tr a-z A-Z`
                       
                        if [ "$p_local_name_to_write" = "$line" ]; then
                                # same name exist in the entry_list_file -> restore delimiter and return.
                                IFS=$IFS_ORG
                                return 1
                        fi
                fi
        done

        # restore delimiter.
        IFS=$IFS_ORG

        # add
        local p_local_entry="'"$2"'"
        ${P_printer_sudo_command}sh -c "echo $p_local_entry >> $1"
       
        return 0
       
}

#################################################################
#### Delete registered entry name from entry_list_file. $1:entry name to delete
#################################################################
p_FUNC_delete_entryname_from_file()
{
        local p_local_list_of_files=""
        local p_local_existentrys=""
        local p_local_list_of_entries=""
        local p_local_out_flg=0

        p_local_list_of_files=`ls ${P_all_entry_list_path}/${P_entry_list_name}* 2> /dev/null`

        if [ $? -ne 0 ]; then
                return 1
        fi

        # set delimiter
        IFS='
'

        #to Upper case
        p_local_target_name=`echo "$1" | tr a-z A-Z`

        for file_name in $p_local_list_of_files; do
                p_local_existentrys=`cat $file_name`

                #-----------------------------
                # Check entry list file (If same name exists, you should not to add entry name)
                #-----------------------------
                p_local_out_flg=0
                p_local_list_of_entries=""
                for line in ${p_local_existentrys}; do
                        if [ -n "$line" ]; then
                                #to Upper case
                                upper_val=`echo "$line" | tr a-z A-Z`
                               
                                if [ "$p_local_target_name" = "$upper_val" ]; then
                                        p_local_out_flg=1
                                        continue
                                else
                                        p_local_list_of_entries=${p_local_list_of_entries}${line}"\n"
                                fi
                        fi       
                done

                # add
                if [ $p_local_out_flg -eq 1 ]; then
                        IFS=$IFS_ORG
                        local p_local_out="'"$p_local_list_of_entries"'"
                        ${P_printer_sudo_command}bash -c "echo -n -e $p_local_out > $file_name"
                        IFS='
'
                fi
        done

        # restore delimiter.
        IFS=$IFS_ORG

        return 0       

}

#################################################################
#### Exec command for printer  $1:command to exec  $2:1..show execution command
#################################################################
p_FUNC_show_and_exec_printer()
{
        if [ $2 -eq 1 ]; then
                printf "$L_INST_COM_01_01" "$1"
        fi
       
        $1 1> /dev/null                #show error message only
        return $?
}

#################################################################
#### Get "cups" command
#################################################################
p_FUNC_get_cupsd_command()
{
        local p_local_service_command_tmp=""
        local p_local_service_command=""
        local p_local_systemctl_command_tmp=""
        local p_local_systemctl_command=""

        #-----------------------------
        # Check "systemctl" command
        #-----------------------------
        p_local_systemctl_command_tmp=`whereis -b systemctl`
        p_local_systemctl_command=`echo -n ${p_local_systemctl_command_tmp} | cut -s -d' ' -f2`
        if [ -n "$p_local_systemctl_command" ]; then
                ${p_local_systemctl_command} status cups.service 1> /dev/null
                if [ $? -eq 0 ]; then
                        P_cupsd_command_current=${P_printer_sudo_command}${p_local_systemctl_command}" restart cups.service"
                        return 0
                fi
        fi

        #-----------------------------
        # Check "service" command
        #-----------------------------
        p_local_service_command_tmp=`whereis -b service`
        p_local_service_command=`echo -n ${p_local_service_command_tmp} | cut -s -d' ' -f2`
        if [ -n "$p_local_service_command" ]; then
                ${P_printer_sudo_command} ${p_local_service_command} cups status 1> /dev/null
                if [ $? -eq 0 ]; then
                        P_cupsd_command_current=${P_printer_sudo_command}${p_local_service_command}" cups restart"
                        return 0
                fi
        fi

        #-----------------------------
        # Check "/etc/init.d/cups"
        #-----------------------------
        if [ -f "$P_cupsd_command_1" ]; then
                P_cupsd_command_current=${P_printer_sudo_command}${P_cupsd_command_1}" restart"
                return 0
        fi
       
        #-----------------------------
        # Check "/etc/init.d/cupsys"
        #-----------------------------
        if [ -f "$P_cupsd_command_2" ]; then
                P_cupsd_command_current=${P_printer_sudo_command}${P_cupsd_command_2}" restart"
                return 0
        fi
       
        return 127        #error

}

#################################################################
#### Get "lpadmin" command
#################################################################
p_FUNC_get_lpadmin_command()
{
        #-----------------------------
        # Check "/usr/sbin/lpamin"
        #-----------------------------
        if [ -f "$P_lpadmin_command_full" ]; then
                P_lpadmin_command_current=${P_printer_sudo_command}$P_lpadmin_command_full
                return 0
        fi
       
        #-----------------------------
        # Get fullpath by "whereis" and check it.
        #-----------------------------
        lpadmin_path_tmp=`whereis -b lpadmin`
        lpadmin_path=`echo ${lpadmin_path_tmp} | cut -d' ' -f2`

        if [ -z "$lpadmin_path" ]; then
                lpadmin_path=`echo ${lpadmin_path_tmp} | cut -d\t -f2`
        fi
       
        if [ "$lpadmin_path" ]; then
                if [ -f "$lpadmin_path" ]; then
                        P_lpadmin_command_current=${P_printer_sudo_command}$lpadmin_path
                        return 0
                fi
        fi
       
        return 127        #error
       
}

#################################################################
#### Select "Yes" or "No". $1:message
#### (Loop until "yes" or "no" selected)
#################################################################
p_FUNC_check_yes_no()
{
        local p_local_result=-1        # neither "Yes" nor "No"

        while [ $p_local_result -eq -1 ]; do
                printf "$1" "[y]"
                read -r CMD

                #Change to uppercase
                CMD=`echo $CMD | tr a-z A-Z`

                case $CMD in
                        "") p_local_result=1;;
                        "Y") p_local_result=1;;
                        "YES") p_local_result=1;;
                        "N") p_local_result=0;;
                        "NO") p_local_result=0;;
                esac

        done
       
        return $p_local_result
}

#################################################################
#### Make entry name to suggest(default value)  $1:base entry name (ex:"MP640")
#################################################################
p_FUNC_make_default_entryname()
{
        local p_local_count=0
        local p_local_entry_name=""
        local p_local_result=""

        p_local_entry_name=$1

        while [ -z "${p_local_result}" ]; do
                if [ $p_local_count -ge 1 ]; then
                        p_local_entry_name=$1"-"$p_local_count
                fi
                p_FUNC_check_entry_exist $p_local_entry_name
               
                if [ $? -ne 0 ]; then
                        p_local_result=""
                else
                        p_local_result=$p_local_entry_name
                fi
                #
                p_local_count=`expr $p_local_count + 1`
               
        done
       
#        echo $p_local_result
        P_DEF_ENTRYNAME=$p_local_result
       
#        return 0
}

#################################################################
#### Check if the entry name exists or not.  $1:entry name to check
####  0:not exist  1:exist in cnij_entrys  2:exist in /etc/cups/ppd
#################################################################
p_FUNC_check_entry_exist()
{
        #-----------------------------
        # Check the return value of "cngpij --checkentryexist entryname" (new)
        #-----------------------------
#        local p_local_entry="'"$1"'"
#        cngpij --checkentryexist "$1" >& /dev/null
        lpstat -p "$1" 1>/dev/null 2>/dev/null
       
        if [ $? -eq 0 ]; then                #exist
                return 1
        fi

        return 0        # Same name is not found
}

#################################################################
#### Check if the entry name is valid.  $1:entry name to check
####  0:invalid  1:valid
#################################################################
p_FUNC_is_valid_entry_name()
{
        local p_local_tmpname=""
       
        p_local_tmpname="$1"

        case "$p_local_tmpname" in
                *[^a-zA-Z0-9\.\+\-\_\@]*)
                        return 0;;        #NG
                *)
                        return 1;;        #OK
        esac
       
}

#################################################################
####
#################################################################
p_FUNC_execute_prepare_process()
{
        local p_local_command=""

        p_local_command=`whereis -b ldconfig | cut -d' ' -f2`
        `${P_printer_sudo_command}${p_local_command}`;
}

#################################################################
#### Make printer list to show from backend output data. S1:USB or LAN string
#################################################################
p_FUNC_make_printer_list_from_backenddata()
{
        # initialize
        local p_local_current_model=""
        local p_local_cn_uri=""
        local p_local_srch_result=""
        local p_local_fax_term=""
        local p_local_dvice_uri=""
        local p_local_ip_add=""
        local p_local_current=""
        local p_local_current_upper=""
        local p_local_display_line=""
        local p_local_current_lowwer=""
        local p_local_is_std_usb_backend=0
        local p_local_is_target_printer=0
        P_target_model_list=""
        P_other_model_list=""
        P_target_model_num=0
        P_other_model_num=0
        P_is_std_usb_backend=0

        # P_DEF_ENTRYNAME:all uppercase..
        p_local_current_model=$P_DEF_ENTRYNAME
       
        # show message...
        printf "\n"
        printf "$L_INST_PRN_01_08"

        #-----------------------------
        # Restart cupsd. (just before device detection)
        #-----------------------------
#        $P_cupsd_command_current restart 1> /dev/null                #show error message only
        $P_cupsd_command_current 1> /dev/null                #show error message only
        if [ $? -ne 0 ]; then
                printf "$L_INST_PRN_01_27"
                exit                #quit immediately
        fi

        #-----------------------------
        # Execute device search
        #-----------------------------
        if [ "$1" = "LAN" ]; then
                p_local_srch_result=`${P_printer_sudo_command}cnijlgmon3 --installer_net`
        else
                p_local_srch_result=`${P_printer_sudo_command}cnijlgmon3 --installer_usb`
        fi

        #-----------------------------
        # Make printer list array with detected printers
        #-----------------------------
        # set delimiter
        IFS='
        '
        for line in ${p_local_srch_result}; do
                #line=`echo -n ${line}`
                #line=${line//\"/\\\"}
       
                # Extract the 3rd field("Canon MX320 series") and set to value.
                #value=`perl -e '"'$line'" =~ /\"(Canon.+?)\"/;print $1'`
                if [ $p_local_is_target_printer -eq 1 ]; then
                        p_local_is_target_printer=`expr $p_local_is_target_printer - 1`
                fi

                value=`expr $line : '.*"\(Canon[^"]*series[^"]*\)"'`
               
                # Skip FAX device
                p_local_fax_term=""
                if [ "$value" ]; then
                        p_local_fax_term=`expr $value : '.*\(FAX\).*$'`
                fi
                if [ "$p_local_fax_term" ]; then
                        continue
                fi
               
                # Extract the 2nd field(/00-1E-8F-0E-1D-44) and set to dvice_uri.
                p_local_cn_uri=`echo ${line} | cut -d' ' -f2`
                p_local_dvice_uri=`echo ${p_local_cn_uri} | cut -d':' -f2`

                # If the I/F is LAN, delete "/" and add IPP address.
                if [ "$1" = "LAN" ]; then
                        #p_local_dvice_uri=`echo ${p_local_dvice_uri} | cut -d'/' -f2`
                        p_local_dvice_uri=`expr ${p_local_dvice_uri} : '.*serial=\(.\+\)'`
                       
                        #p_local_ip_add=`perl -e '"'$line'" =~ /\"(IP.+)\"/;print $1'`
                        p_local_ip_add=`expr $line : '.*"\(IP[^"]*\).*$'`
                        #p_local_ip_add=`echo $p_local_ip_add | sed -e "s/^IP://" `        #new
                        p_local_ip_add=`expr $p_local_ip_add : 'IP:\(.\+\)'`
                       
                        p_local_dvice_uri=$p_local_dvice_uri" "$p_local_ip_add
                       
                fi

                if [ "${value}" != "" ]; then
                        p_local_current=`echo ${value} | cut -d' ' -f2`
                        p_local_current_upper=`echo $p_local_current | tr a-z A-Z`

                        # fix backend
                        P_is_std_usb_backend=${p_local_is_std_usb_backend}

                        for printer in ${P_support_printer[@]}; do
                                if [ "${p_local_current_upper}" = "${printer}" ]; then        # If target model..
                                       
                                        P_target_model_num=`expr $P_target_model_num + 1`        # array number starts with "1".
                                        p_local_display_line="${P_target_model_num}) ${value} (${p_local_dvice_uri})"
                                        P_target_model_list[P_target_model_num]=$p_local_display_line
                                        p_local_is_target_printer=`expr $p_local_is_target_printer + 1`
                                        break
                                fi
                        done

                        if [ $p_local_is_target_printer -ne 1 ]; then
                                # Need check PPD folder
                                # If other model...
                               
                                p_local_current_lowwer=`echo $p_local_current_upper | tr A-Z a-z`
                                ppdname="canon${p_local_current_lowwer}"
                               
                                for filepath in ${C_ppdfile_path}
                                do
                                        ppd_device_name=`basename $filepath .ppd`

                                        if [ $ppdname = $ppd_device_name ]; then
                                                #check is support PWGRaster                       
                                                grep -q $raster_command $filepath
                                                if [ $? -eq 0 ]; then
                                                        P_other_model_num=`expr ${P_other_model_num} + 1`                # arrya number starts with "101".
                                                        p_local_display_line="`expr $P_other_model_num + 100`) ${value} (${p_local_dvice_uri})"
                                                        P_other_model_list[P_other_model_num]=$p_local_display_line
                                                fi
                                        fi
                                done
                        fi
                fi
        done
       
        # restore delimiter
        IFS=$IFS_ORG
       
#        echo "P_target_model_num=$P_target_model_num"
#        echo "P_other_model_num=$P_other_model_num"
       
}

#################################################################
#### Select device from printer lists menu. S1:backend name
#################################################################
p_FUNC_select_printer_from_list()
{
       
        P_ans=''
        local p_local_defaultnum
        local p_local_target_list_title
        local p_local_other_list_title
        local p_local_current_num
        local p_local_indata
        local p_local_indata_for_array

        #-----------------------------
        # Set default selection.
        #-----------------------------
        if [ $P_target_model_num -eq 0 ]; then
                p_local_defaultnum=0
        else
                p_local_defaultnum=1
        fi
       
        # Set list titles according to backend name.
        if [ "$1" != "LAN" ]; then
                p_local_target_list_title="$L_INST_PRN_01_14"
                p_local_other_list_title="$L_INST_PRN_01_15"
        else
                p_local_target_list_title="$L_INST_PRN_01_12"
                p_local_other_list_title="$L_INST_PRN_01_13"
        fi

        #-----------------------------
        # Show printer list
        #-----------------------------
        printf "\n"
        printf "\n"
        printf "#=========================================================#\n"
        printf "#  $L_INST_PRN_01_09"
        printf "#=========================================================#\n"
        printf "$L_INST_PRN_01_10"
        printf -- "-----------------------------------------------------------\n"
        printf " 0) $L_INST_PRN_01_11\n"
        printf -- "-----------------------------------------------------------\n"
   
    if [ $P_target_model_num -gt 0 ]; then
            printf "$p_local_target_list_title"
#                for current in ${P_target_model_list[@]}; do
#                echo $current
#                done
                for (( i=0; i<$P_target_model_num; i++ ))
                {
                        p_local_current_num=`expr $i + 1`
                        echo ${P_target_model_list[p_local_current_num]}
                }
        else
            printf "$L_INST_PRN_01_18"
        fi

        echo "-----------------------------------------------------------"

    if [ $P_other_model_num -gt 0 ]; then
                  printf "$p_local_other_list_title"
        #        for current in ${P_other_model_list[@]}; do
        #                echo $current
        #        done
                for (( i=0; i<$P_other_model_num; i++ ))
                {
                        p_local_current_num=`expr $i + 1`
                        echo ${P_other_model_list[p_local_current_num]}
                }
                echo "-----------------------------------------------------------"
        fi

        #-----------------------------
        # Show default choice
        #-----------------------------
        if [ $p_local_defaultnum -eq 0 ]; then
                printf "$L_INST_PRN_01_16" "[0]" "$L_INST_PRN_01_11" > /dev/stderr
       
        else
                tmp_selected=${P_target_model_list[${p_local_defaultnum}]}
                tmp_selected=`echo $tmp_selected | cut -d " " -f 2-`
                printf "$L_INST_PRN_01_16" "[1]" "$tmp_selected" > /dev/stderr
        fi
       

        #-----------------------------
        # Loop until valid selection is done...
        #-----------------------------

        # set delimiter
        IFS='
'
        while [ -z "${P_ans}" ]; do
               
                # Please select...
                printf "$L_INST_PRN_01_17 [${p_local_defaultnum}]" > /dev/stderr
                IFS=$IFS_ORG
                read -r p_local_indata
                IFS='
'

                # Enter(not select number) -> deault value selected
                if [ "${p_local_indata}" = "" ] ; then
                        p_local_indata=${p_local_defaultnum}
                fi
               
                # Check the inputted data.
                #to Upper case
                p_local_indata=`echo $p_local_indata | tr a-z A-Z`
               
                case "$p_local_indata" in

                        # "0"(re-search) -> return 0 immediately
                        "0")
                                # restore delimiter and return.
                                IFS=$IFS_ORG
                                return 1;;

                        # "Q"(quit) -> return 2 immediately
                        "Q")
                                # restore delimiter and return.
                                IFS=$IFS_ORG
                                return 2;;

                        *[^0-9]*)
                                # contain characters other than number(0-9).-> invaild -> back to input step.
                                P_ans='';;
                               
                        *)
                                # valid -> go to next step.
                                # Verify inputted value
                                # Check if the choice is target model or not.
                               
                                if [ "${p_local_indata}" -ge 1 -a "${p_local_indata}" -le 100 ] 2> /dev/null; then        #1-100: target model
                                        if [ "${p_local_indata}" -ge 1 -a "${p_local_indata}" -le "${P_target_model_num}" ] 2> /dev/null; then
                                                P_ans=${P_target_model_list[${p_local_indata}]}
                                        else
                                                :
                                        fi
                                else                                                                                                                                #101-: other model
                                        p_local_indata_for_array=`expr $p_local_indata - 100`
                                        if [ "${p_local_indata_for_array}" -ge 1 -a "${p_local_indata_for_array}" -le "${P_other_model_num}" ] 2> /dev/null; then
                                                P_ans=${P_other_model_list[${p_local_indata_for_array}]}
                                        else
                                                :
                                        fi
                                fi
                esac
        done
       
        #echo "select num is ${P_ans}"
       
        # restore delimiter and return.
        IFS=$IFS_ORG
        return 0

}

#################################################################
#### Make DeviceURI  $1:USB or LAN string, $2:printer list line
#################################################################
p_FUNC_make_uri()
{
        # set delimiter
        IFS='
        '
#        echo "choice=$2"
        local p_local_uri=""
       
        # Extract "00-00-85-CE-9B-17 172.21.81.49"or"/dev/usb/lp0"
        #p_local_uri=`perl -e '"'$2'" =~ /\((.+)\)/;print $1'`
        p_local_uri=`expr $2 : '.*(\(.\+\)).*$'`
       
        # If I/F is LAN: "00-00-85-CE-9B-17 172.21.81.49" -> "00-00-85-CE-9B-17" -> "/00-00-85-CE-9B-17"
        if [ "$1" = "LAN" ]; then        #LAN
                p_local_uri=`echo $p_local_uri | cut -d' ' -f1`
                p_local_uri="//Canon/?port=net&serial="$p_local_uri
        fi

        P_current_uri=$p_local_uri
#        echo P_current_uri="$P_current_uri"
        # restore delimiter
        IFS=$IFS_ORG
       
}

#################################################################
#### Entry creation main  $1:complete message  $2:device("mp640series")  $3:system("rpm")
#################################################################
P_FUNC_MAIN_make_queue()
{
        IFS_ORG=$IFS

        #echo ""
        #echo "## Driver packages installed. ##"
       
        P_printer_device=" "
       
        # make P_print


BW-userx 02-08-2018 03:13 PM

will dos2linux work on that?


All times are GMT -5. The time now is 09:01 AM.