programme is ok but not working in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting programme is ok but not working in script
# 1  
Old 02-04-2011
Data programme is ok but not working in script

hi buddies;

i have a very strange problem. i made a script composed of just 5 line. it is containing awk and nawk codes and it is working perfectly when it is applied one-by-one (copy & paste).
but when i type run myscript.mos, it is giving:
Code:
nawk: syntax error at source line 1
context is
bla bla bla...

error??? SmilieSmilie
how can this strange situation happen in such a strange manner??

note: i'm on Solaris.
# 2  
Old 02-04-2011
can you copy and paste the script's contents here? It makes helping you much easier when we can see where your mistake might be

lol the "blah blah blah" might be the most important part fyi, so always include WHAT you're trying to do, AND the EXACT error message
# 3  
Old 02-04-2011
ok. this is my code:
Code:
1> l nawk 'NR==FNR{a=a?a"get . "$0";":"get . "$0";";next;}{print "l ./moshell "$0" "c"lt all;l+;" a "l-;l cat $logfile >>
 /home/gc_sw/log.txt;l rm $logfile"c}' c="'" /home/gc_sw/params.txt /home/gc_sw/ip.txt > /home/gc_sw/command.mos
2> run /home/gc_sw/command.mos
3> l awk ' $2 ~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ {print "\n" $2 }  NF == 3 && $1 ~ /^.*=.*$/ {print $0 }' 
/home/gc_sw/log.txt > /home/gc_sw/1.txt
4> l nawk '/^[0-9]/&&p!=$1{printf "\n%s",p=$1} NF>1{$1=$1;sub($1" "$2" ","\t"$1"\t"$2"\t");print}' 
/home/gc_sw/1.txt > /home/gc_sw/sitedata.xls
5> l rm /home/gc_sw/command.mos /home/gc_sw/log.txt  /home/gc_sw/1.txt

Code:
1st line: process params.txt and ip.txt and write result (write "l. /moshell ...") to command.mos
2nd line: run command.mos
3rd line: text formatting
4th line: text formatting
5th line: remove unnecessary files

when i try to run this script, error is:

Code:
192.168.1.1> run get.mos //i have typed this and script is starting

192.168.1.1> l nawk 'NR==FNR{a=a?a"get . "$0";":"get . "$0";";next;}{print "l ./moshell "$0" "c"lt all;l+;" a "l-;l cat $logfile >> /home/gc_sw/log.txt;l rm $logfile"c}' 
c="'" /home/gc_sw/params.txt /home/gc_sw/ip.txt > /home/gc_sw/command.mos

nawk: syntax error at source line 1
 context is
        NR==FNR{a=a?a"get . "run >>>  get. <<< mos ";":"get . "run get.mos ";";next;}{print "l ./moshell "run get.mos " "c"lt all;l+;" a "l-;l cat
 $logfile >> /home/gc_sw/log.txt;l rm $logfile"c}
nawk: illegal statement at source line 1

192.168.1.1> run /home/gc_sw/command.mos

192.168.1.1> l awk ' $2 ~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ {print "\n" $2 }  NF == 3 && $1 ~ /^.*=.*$/ {print $0 }' /home/gc_sw/log.txt > /home/gc_sw/1.txt

awk: can't open /home/gc_sw/log.txt

192.168.1.1 l nawk '/^[0-9]/&&p!=$1{printf "\n%s",p=$1} NF>1{$1=$1;sub($1" "$2" ","\t"$1"\t"$2"\t");print}' /home/gc_sw/1.txt > /home/gc_sw/sitedata.xls

192.168.1.1> l rm /home/gc_sw/command.mos /home/gc_sw/log.txt  /home/gc_sw/1.txt /home/gc_sw/log.txt: No such file or directory

192.168.1.1> waiting for command

1st line of command is running with error!
# 4  
Old 02-04-2011
Questions:
Code:
What is "run" ?
What is "l" ?      (It's usually an alias for "ls").

What Operating System version?
What Shell?
Code:
uname -a
echo $SHELL

# 5  
Old 02-04-2011
i am using MOshell interface being started from a Unix Terminal.

Code:
run : a moshell command to execute .mos file.
l : at moshell session, type "l" and then write unix commands. it is something like "opening a unix channel"

my OS is: Solaris

Code:
> uname -a
SunOS uas 5.10 Generic_127127-11 sun4u sparc SUNW,Sun-Fire-V440

> echo $shell
/usr/bin/tcsh

# 6  
Old 02-04-2011
As I neither use "tcsh" or "MOshell" its time to back off. In reading about MOshell I did notice that people escape underscore characters in external commands for some reason \_ .

What you are attempting looks complex and the mixture of syntax is difficult to follow. Any way you can get the external commands into unix scripts?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

2. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

3. Programming

Help for coding this programme

for a floating-point array x whose size is n, find the geometric mean.. GM =n x1.x2.x3...xn (2 Replies)
Discussion started by: allyjaah
2 Replies

4. Programming

starting programme in C

hello, For school i make the next mission: give how many chambers in a constant number. use an array which chamber is free and count how many chamber there are free. make also something to test I don't now how to start. I need an well example so i can make the mission thank you (1 Reply)
Discussion started by: wouter88
1 Replies

5. Programming

help with C programme to lock remote resources

hello every one i am working on a project to lock remote computer resources(hard drive, usb, cd- rom, folder etc). i have maintained connection using JAVA RMI and using JAVA JNI to lock resources, now i am really stuck up with C programme to do actual locking, i am using RHL-5 on admin computer... (7 Replies)
Discussion started by: zius_oram
7 Replies

6. Programming

cobol programme

I have some compile programme .crn now I want to run .crn programme on express cobol which allow only *.gnt programme any solution to run *.crn programme (0 Replies)
Discussion started by: bibi
0 Replies

7. Shell Programming and Scripting

snmpget in a perl programme

Hi Guyz can u tell me how to write a programme in perl using snmpget. Regards' Harrr (0 Replies)
Discussion started by: Harikrishna
0 Replies

8. Programming

Need help in a c programme

Dear Friends, I ve two text files like re_im.dat 13.7663000000 5.9572200000 10.2682000000 10.9345000000 5.0810700000 14.1132000000 two real values per row Sarf.dat 127 128 128 128 71 0 128 128 128 128 71 0 128 128 128 128 71 0 This is having 6... (2 Replies)
Discussion started by: user_prady
2 Replies

9. Shell Programming and Scripting

want to use output of c programme in expect

hi i am having a c code which gives the output of my password in text format i.e when i run my c code which which gives the password asfollows====>>>>>> $./passwdprogram ======>>>>>>abc@123(this is the output) now i have an expect script to remotely ssh which uses the password set in ... (0 Replies)
Discussion started by: xander
0 Replies

10. UNIX for Dummies Questions & Answers

Unable to compile the c programme in unix

Hi, My name is vreddy and I am learning c language now and written one programme on vi editor. how do I compile the programme please give me some advice and that would be helpfull for me. thanks vre (10 Replies)
Discussion started by: vasudeva
10 Replies
Login or Register to Ask a Question