Windows to UNIX issues

Hi, a script was used on Windows using MKS Toolkit. I'm trying to move it to a unix machine but it gets all errors. At first I had things like: syntax error: `in^M' unexpected

I still get these but I've been building it up slowly to try and find/remove problems. The current is: syntax error: `while' unmatched

It's not even letting me do a while loop. Anyone notice the problem?

while :
do
read ANS?"text..."
echo $ANS
esac
done

When I include:

trap "stty sane;echo '\n\n   *** Abnormal exit ***';exit" 1 2 3 4 5 6 7 8 9 15

I get: trap: bad signal 15

Thanks for any help.

The actual script looks like this: http://pastebin.ca/1891102

while :
do
  echo "text..."
  read ANS
  echo $ANS

done

That is an infinite loop, meaning it won't end unless the user presses ctrl/c or maybe ctrl/d.

You cannot trap signal 9. The error you have is that signal 15 is apparently not defined on your system.

kill -l

That is a lowercase -L will show you the signals on your system.

while transfering the files from Windows using ftp set the transmission mode as "Ascii" instead of Binary in order to avoid ^M characters.

1 Like

Thanks expert...I set it to text transfer & it worked fine. Now Io go through figuring out why errors appear =]
Any idea why:

export ORCL_SQL="${HKTMP}/orcl.sql"
>$ORCL_SQL
[[ -s $ORCL_SVC ]] || return
cat << _EOT_ >$ORCL_SQL
...

Would lead to the error: cannot create /hk_9.2/tmp/orcl.sql: No such file or directory ?

I'm logged in as a super user~ (oracle) so it shouldn't be a privileges issue. The file already exists in the folder.

Please post the output of:

id
ls -lad /hk_9.2
ls -ald /hk_9.2/tmp
ls -lad /hk_9.2/tmp/orcl.sql

Hi,

Sorry that was a problem of not referencing correctly in the variables. Instead of currentfolder/deeperfolder like in Windows I had the variable just refer to the deeper folder. I now have a problem where it says: CAT: not found

I've googled but haven't found this problem and the line just points to a "}". Has anyone come across this error before & is able to suggest a reason?

Thanks for help.

UNIX, unlike Windows, is case-sensitive concerning path names and commands. Check your script if you're perhaps calling the "cat" utility as "CAT".

1 Like

Thanks for the info pludi. There was reference to CAT instead of cat and once it was changed the script worked.

Thanks <3

---------- Post updated at 05:03 AM ---------- Previous update was at 04:10 AM ----------

The next error I can't manage to fix (or google) is: stty: invalid argument `-oproc'
It's from the line: echo "$PROMPT\c"; stty -oproc; read ANS

I tried just removing the -oproc but I get: speed 38400 baud; line = 0;
being displayed.

I tried removing the stty part all together but it becomes a never ending loop (loop only ends when S or D is specified but without the stty S or D isn't accepted either despite the rest appearing right).

Here's the function for more info on the code: pastebin - Stuff - post number 1892380

What Operating System are you running?
If a "stty" command is not in a "stty -a" display, it does not exist.
You may have to omit the "stty -oproc" command completely and redesign your screen layout. Interfering with what happens when the user enters data is not normal practice.

1 Like

Hi,

The script was initially on a windows machine with MKS Toolkit. oproc is a command for that which "Corresponds to the Win32 ENABLE_PROCESSED_OUTPUT mode. Allows ASCII control sequences and backspace, tab, bell, carriage return, and linefeed to be processed by the system. If this mode is not set, then these special ASCII characters simply appear on the screen as special characters, rather than the appropriate motion (or sound, in the case of the bell character)."

I guess I need a UNIX equivalent (its now on unix...or maybe RH). I tried changing it to ; stty -a; but it threw out a load of text (possible -commands).

Edit: Ok it was a problem with case. I guess in windows it wasn't case sensitivie and so:
get_ans " (S)ummary or (D)etailed report ? " "s d"
worked. When I enter 's' it is treated as 'S' but the variables passed remain as 's' so they never match. Thanks for trying to help though.

Is an enquiry about all the current "stty" settings for your terminal. You can then see what they mean in "man stty". Your error message was because "stty -opost" is invalid on your Operating System.