Sample Header Ad - 728x90

Script portability to MacOS

0 votes
0 answers
64 views
Context === Catalina (zsh) & Homebrew: man pages return successfully for pdftk & ps2pdf The goal is to execute: pdfBatesStamp.sh as described in https://unix.stackexchange.com/a/115537/182280 I changed the first line of the script to: #!/bin/zsh - Observations === Preliminary test returned: enter image description here The error: : command not foundine XX: are lines with no commands / comments. Screenshot shows lines 104,105,109,111 are null: enter image description here UPDATE: said error is remedied by placing a # at the start of the line. Line 132: enter image description here Questions === 1. What exactly is causing said errors? 2. What is the remedy? 3. Is there any reason that this script will NEVER run in said context? For jsbillings === user@JUPITER pdfBatesStamp % ./pdfBatesStamp.sh Exhibits_ActivityReport.pdf ./pdfBatesStamp.sh:59: command not found: ^M ./pdfBatesStamp.sh:132: parse error near `elif' user@JUPITER pdfBatesStamp % user@JUPITER pdfBatesStamp % sh pdfBatesStamp.sh Exhibits_ActivityReport.pdf pdfBatesStamp.sh: line 132: syntax error near unexpected token `elif' 'dfBatesStamp.sh: line 132: `elif [ $# -eq 2 ]; then Ubuntu 16.04 Test results: user@azimuth:~/Desktop/BatesStamp$ cp pdfBatesStamp.sh test.sh user@azimuth:~/Desktop/BatesStamp$ dos2unix test.sh dos2unix: converting file test.sh to Unix format ... user@azimuth:~/Desktop/BatesStamp$ ls Exhibits_ActivityReport.pdf pdfBatesStamp.sh test.sh user@azimuth:~/Desktop/BatesStamp$ ls -l total 11384 -rw------- 1 user user 11589045 Nov 23 18:00 Exhibits_ActivityReport.pdf -rwxrwxr-x 1 user user 32764 Nov 23 22:24 pdfBatesStamp.sh -rwxrwxr-x 1 user user 32764 Nov 23 22:26 test.sh user@azimuth:~/Desktop/BatesStamp$ ./test.sh Exhibits_ActivityReport.pdf Input File = "/home/user/Desktop/BatesStamp/Exhibits_ActivityReport.pdf" (origSize=11,589,045) (standard_in) 1: syntax error (standard_in) 1: illegal character: M (standard_in) 1: syntax error (standard_in) 1: syntax error (standard_in) 1: syntax error ./test.sh: line 384: [: too many arguments *** Can't find page size user@azimuth:~/Desktop/BatesStamp$ mac2unix test.sh mac2unix: converting file test.sh to Unix format ... user@azimuth:~/Desktop/BatesStamp$ ./test.sh Exhibits_ActivityReport.pdf Input File = "/home/user/Desktop/BatesStamp/Exhibits_ActivityReport.pdf" (origSize=11,589,045) (standard_in) 1: syntax error (standard_in) 1: illegal character: M (standard_in) 1: syntax error (standard_in) 1: syntax error (standard_in) 1: syntax error ./test.sh: line 384: [: too many arguments *** Can't find page size
Asked by gatorback (1522 rep)
Nov 24, 2021, 02:08 AM
Last activity: Nov 24, 2021, 03:30 AM