C Shell script not run with Windows 10


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting C Shell script not run with Windows 10
# 1  
Old 07-28-2018
C Shell script not run with Windows 10

Hi all,
I have a script has been writing for Unix or Linux. Now I want to run under Windows 10. is give me Error:
Code:
if:Badly formed number

How to fix this please help
Code:
*** This is a copy of a part of Script. 

set absolute_gap = 0
		if ($min_p_to_p != "" && $min_p_to_p != "N/A" && $min_p_to_t != "" && $min_p_to_t != "N/A" && $min_t_to_t != "" && $min_t_to_t != "N/A") then
			set compare_val_a = `float_expr2 " $min_p_to_p \* 1000 "`
			if (`echo $compare_val_a | grep -c .` > 0) then
				set compare_val_a = `echo $compare_val_a | $AWK -F. '{print $1}'`
			endif
			set compare_val_b = `float_expr2 " $min_p_to_t \* 1000 "`
			if (`echo $compare_val_b | grep -c .` > 0) then
				set compare_val_b = `echo $compare_val_b | $AWK -F. '{print $1}'`
			endif
			set compare_val_c = `float_expr2 " $min_t_to_t \* 1000 "`
			if (`echo $compare_val_c | grep -c .` > 0) then
				set compare_val_c = `echo $compare_val_c | $AWK -F. '{print $1}'`
			endif

Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments.

Last edited by Don Cragun; 07-28-2018 at 08:46 PM.. Reason: Add missing CODE tags.
# 2  
Old 08-06-2018
As a basic rule, have each $variable in quotes -> "$variable"
The quotes prevent the shell from trying additional expansions on it.
Code:
                if ("$min_p_to_p" != "" && "$min_p_to_p" != "N/A" && "$min_p_to_t" != "" && "$min_p_to_t" != "N/A" && "$min_t_to_t" != "" && "$min_t_to_t" != "N/A") then
                        set compare_val_a = `float_expr2 " $min_p_to_p \* 1000 "`
                        if (`echo "$compare_val_a" | grep -c .` > 0) then
                                set compare_val_a = `echo "$compare_val_a" | "$AWK" -F. '{print "$1"}'`
                        endif
                        set compare_val_b = `float_expr2 " $min_p_to_t \* 1000 "`
                        if (`echo "$compare_val_b" | grep -c .` > 0) then
                                set compare_val_b = `echo "$compare_val_b" | "$AWK" -F. '{print "$1"}'`
                        endif
                        set compare_val_c = `float_expr2 " $min_t_to_t \* 1000 "`
                        if (`echo "$compare_val_c" | grep -c .` > 0) then
                                set compare_val_c = `echo "$compare_val_c" | "$AWK" -F. '{print "$1"}'`
                        endif

Further, your script seems to require an external program "float_expr2". Is it present in your environment?

Last edited by MadeInGermany; 08-07-2018 at 12:18 PM.. Reason: Added the given code with quotes
# 3  
Old 08-06-2018
Hi MadeinGermany,
Please tell me more about "float_expr2" in the system environment.
Is any executable file has to be installed before then?
# 4  
Old 08-07-2018
Yes I guess so, because your program code runs it.

While your error message is not related to it.
BTW
Code:
if (`echo "$compare_val_a" | grep -c .` > 0)

is correct but can be simplified
Code:
if ("$compare_val_a" != "")

# 5  
Old 08-07-2018
Thank you but it does not work
Code:
    set absolute_gap = 0
        if ($min_p_to_p != "" && $min_p_to_p != "N/A" && $min_p_to_t != "" && $min_p_to_t != "N/A" && $min_t_to_t != "" && $min_t_to_t != "N/A") then
            set compare_val_a = `float_expr2 " $min_p_to_p \* 1000 "`
            if ("$compare_val_a" !="") then
                set compare_val_a = `echo $compare_val_a | $AWK -F. '{print $1}'`
            endif
            set compare_val_b = `float_expr2 " $min_p_to_t \* 1000 "`
            if ("$compare_val_b" !"") then
                set compare_val_b = `echo $compare_val_b | $AWK -F. '{print $1}'`
            endif
            set compare_val_c = `float_expr2 " $min_t_to_t \* 1000 "`
            if ("$compare_val_c" !"") then
                set compare_val_c = `echo $compare_val_c | $AWK -F. '{print $1}'`
            endif


Last edited by MadeInGermany; 08-07-2018 at 12:41 PM.. Reason: added code tags
# 6  
Old 08-07-2018
Please do precisely what I told you! Corrections in red:
Code:
    set absolute_gap = 0
        if ("$min_p_to_p" != "" && "$min_p_to_p" != "N/A" && "$min_p_to_t" != "" && "$min_p_to_t" != "N/A" && "$min_t_to_t" != "" && "$min_t_to_t" != "N/A") then
            set compare_val_a = `float_expr2 " $min_p_to_p \* 1000 "`
            if ("$compare_val_a" != "") then
                set compare_val_a = `echo "$compare_val_a" | "$AWK" -F. '{print $1}'`
            endif
            set compare_val_b = `float_expr2 " $min_p_to_t \* 1000 "`
            if ("$compare_val_b" != "") then
                set compare_val_b = `echo "$compare_val_b" | "$AWK" -F. '{print $1}'`
            endif
            set compare_val_c = `float_expr2 " $min_t_to_t \* 1000 "`
            if ("$compare_val_c" != "") then
                set compare_val_c = `echo "$compare_val_c" | "$AWK" -F. '{print $1}'`
            endif

Please do not say "does not work"! Instead say "I got the following error" or "the following happened" and give a better description.
And please, put your code or error message in "code" tags (one of the formatting icons at the top of the Wiki editor).
This User Gave Thanks to MadeInGermany For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

To run a shell script in remote server from windows batch file

Hi all, i need to run a shell script on remote server. I have created file .bat file in windows server with following code, c:\Users\Desktop\putty.exe -ssh -pw password user@server ./script.sh i need to run the script.sh in my remote server Above command is not working, any... (4 Replies)
Discussion started by: rammm
4 Replies

3. Shell Programming and Scripting

Run awk script on windows?

Hi , I am struck with one problem here. I have awk script which deals with a log file and gives result. It works perfect on linux. But my problem is I want to run it on windows. How I can run my awk script on windows? Please guide me on this. how to proceed further? Thanks pamu (5 Replies)
Discussion started by: pamu
5 Replies

4. Shell Programming and Scripting

Run KSH script in Windows machine

Hi i created a unix script ksh that goes to a specific folder/xyz/abc, searches for all the .txt files in it and perform some operation on these text file. It runs well in Unix server(machine) Now this script needs to be run on a windows machine having the same folder structure(that is look... (1 Reply)
Discussion started by: mad_man12
1 Replies

5. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

6. Shell Programming and Scripting

How to run cmds after changing to a new env (shell) in a shell script

Hi, I am using HP-UNIX. I have a requirement as below I have to change env twice like: cadenv <env> cadenv <env> ccm start -d /dbpath ccm tar -xvf *.tar ccm rcv .... mv *.tar BACKUP but after I do the first cadenv <env> , I am unable to execute any of the later commands . ... (6 Replies)
Discussion started by: charlei
6 Replies

7. Shell Programming and Scripting

Help need to make a shell script run for ffmpeg vhook watermaking in shell

i have a small problem getting a batxh shell script to run in shell this is the code the problem seems to be centered around the ffmpeg command, something maybe to do with the ' ' wrapping around the vhook part command this is a strange problem , if i take the ffmpeg command and... (1 Reply)
Discussion started by: wingchun22
1 Replies

8. Shell Programming and Scripting

How to Run a shell script from Perl script in Parent shell?

Hi Perl/UNIX experts, I have a problem in running a shell script from my perl script (auto.pl). I run the perl script using perl auto.pl from the shell prompt The shell script picks the files in "input" folder and procesess it. The shell script blue.sh has this code. export... (16 Replies)
Discussion started by: hifake
16 Replies

9. Linux

Possible ways to run shell scripts on Windows

Hi all, I want to know possible ways to exceute the shell scripts on Windows environment. Please help me. Regards, Uday. (2 Replies)
Discussion started by: uday123
2 Replies
Login or Register to Ask a Question