Invalid null command error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Invalid null command error
# 1  
Old 06-19-2013
Invalid null command error

Hi,

I have this script which gives me output as Invalid null command

Code:
set recent_file=`grep '^-.*xlsx$' $FTP_LOG |\
                      sed -e 's/Jan/1/g'    \
                          -e 's/Feb/2/g'    \
                          -e 's/Mar/3/g'    \
                          -e 's/Apr/4/g'    \
                          -e 's/May/5/g'    \
                          -e 's/Jun/6/g'    \
                          -e 's/Jul/7/g'    \
                          -e 's/Aug/8/g'    \
                          -e 's/Sep/9/g'    \
                          -e 's/Oct/10/g'   \
                          -e 's/Nov/11/g'   \
                          -e 's/Dec/12/g' | \
                      sort -k8n -k6n -k7n | \
                       awk '{file=$NF}END{print file}'`

echo "Most Recent File name: " $recent_file

I know csh is not good to use, but I have to use cshonly on SunOS.... Any idea what is wrong with this script?
# 2  
Old 06-19-2013
UNIX, all UNIX, has the bourne shell available. It's necessary for far too many things to get rid of. If anyone tried, they'd break their system.

So, rejoice. You are not restricted to csh after all.
# 3  
Old 06-19-2013
I understand that... even I don't like csh.. Smilie
but the thing is that I am modifying an existing shell script....which was primarily written for csh... this is very huge script... am working on a very small part of it..
# 4  
Old 06-19-2013
I have never worked with any csh variant, but, at least with some implementations, you can get trace data if you set the echo and verbose variables (set echo verbose). Seeing the commands before and after expansions might help you spot the null command.

Regards,
Alister

Last edited by alister; 06-19-2013 at 03:44 PM..
This User Gave Thanks to alister For This Post:
# 5  
Old 06-19-2013
You were hit by a parser bug:
Code:
echo a\
b\
c
a b c

Code:
echo `echo a\
b\
c`
a

the next lines are not appended and missing in the output.
The bug is fixed in recent versions of tcsh.

BTW if you omit the "set", it will work in sh,ash,dash,bash,ksh,zsh,...

Last edited by MadeInGermany; 06-19-2013 at 04:56 PM..
This User Gave Thanks to MadeInGermany For This Post:
# 6  
Old 06-19-2013
when I write all grep, sed, awk, sort commands in one line, instead of using \ to extend them in the next line, set var=`myScript` works very well...

---------- Post updated at 04:25 PM ---------- Previous update was at 04:17 PM ----------

Quote:
Originally Posted by MadeInGermany
You were hit by a parser bug:
Code:
echo a\
b\
c
a b c

Code:
echo `echo a\
b\
c`
a

the next lines are not appended and missing in the output.
The bug is fixed in recent versions of tcsh.

BTW if you omit the "set", it will work in sh,ash,dash,bash,ksh,zsh,...
Thanks for the reply.
But, your example is working just fine ...
Code:
echo a\
> b\
> c
abc

echo `echo a\
> b\
> c`
abc

.. and I am on csh...

I guess somewhere down the line, \ is the culprit .... need to get rid of it...

Thank you all for the time you spent on this .... Smilie
# 7  
Old 06-19-2013
Quote:
Originally Posted by juzz4fun
I guess somewhere down the line, \ is the culprit .... need to get rid of it...
Just so. Some versions of csh have bugs related to it. The ad-hoc parser strikes again.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Eeprom security-mode=command cause invalid login

Hi there, In Solaris 8. I have accidentally set the eeprom security-mode=command because I followed the CIS benchmark guideline. Initally, it was eeprom security-mode=none. I have tried to login with the correct password numerous time and it still say permission denied. I have tried to login... (4 Replies)
Discussion started by: alvinoo
4 Replies

2. Shell Programming and Scripting

How to loop read command and print valid invalid states.?

My question is how would i loop a read command to keep asking the user for input and eventually print the no. of valid invalid inputs after a specified control input typed i.e. (-3). (1 Reply)
Discussion started by: Flowoftruth
1 Replies

3. Shell Programming and Scripting

FTP - Invalid command

Hi All, OS - Linux I wrote a ftp program to download a file. the file is downloading successfully, but a negative message is prompting. i placed set -vx in code to trace. #!/usr/bin/ksh set -vx st_date=$(date) Logfile=/home/user/ftp_dwnload.$st_date.log cd /home/usr/data/ print... (1 Reply)
Discussion started by: nag_sathi
1 Replies

4. Shell Programming and Scripting

sed error: invalid reference

Hello all, I am using sed to parse a particular part of a string and am having problems. I am getting the following error: sed: -e expression #1, char 28: invalid reference \1 on `s' command's RHS Here is the code I am using: echo "Alarm SET:" echo "" echo "Date: " $DATE echo... (4 Replies)
Discussion started by: dlundwall
4 Replies

5. HP-UX

ERROR[55]: Invalid or inaccessible system ID

Hi all, I was changing a motherboard which has the MP console down on an rx4640. I am receiving the following error: ERROR: Invalid or inaccessible system ID(s) then it takes me to the EFI where it doesn't boot from the primary path. I contacted a colleague who already replaced two... (0 Replies)
Discussion started by: MazenH
0 Replies

6. Shell Programming and Scripting

useradd: ERROR: invalid syntax

Hello - I have the below script syncToken=None;\ forceDeleteUserHome=true;\ nisPwdDir=/etc;\ mirrorFilesLocation=/etc/connector_mirror_files;\ removeHomeDirContents=true;\ shadow=false;\ connectorPrompt=#;\ nisBuildDirectory=/var/yp;\ PGROUP=nogroup;\ COMMENTS='Comments\\ with\\... (2 Replies)
Discussion started by: manju--
2 Replies

7. Shell Programming and Scripting

?Invalid Command

when i am executing the script i am getting ?Invalid command though the script is right. Could any one please let me know how to overcome this problem. Urgent Please Thanks a lot in advance (2 Replies)
Discussion started by: Olivia
2 Replies

8. Shell Programming and Scripting

invalid null command

#! /bin/csh set pattern = "" set deli = | foreach i ( `cat pattern`) set pattern = "$pattern$deli$i" end all i want to accomplish is create a string a|b|c, but instead I got an invalid null command error, thanks for your help (1 Reply)
Discussion started by: jdsignature88
1 Replies

9. Shell Programming and Scripting

Invalid Command Name

I have telnet to a machine and executed some commands in it. pls see below : #!/usr/bin/expect spawn telnet 170.10.11.1 2100 expect "login:" send username\r expect "password:" send password\r expect "$" send "touch filetest\r" expect "$" send exit\r expect... (3 Replies)
Discussion started by: sudharsan23
3 Replies

10. Shell Programming and Scripting

01.30 Invalid shell error

Hi, I am getting the error 01.30 Invalid shell error I am running the bash shell script in the korn login shell. I have mentioned the #!/bin/bash statement in the my script but not sure why it is giving this error to me.. (4 Replies)
Discussion started by: mr_harish80
4 Replies
Login or Register to Ask a Question