Error while running as shell script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error while running as shell script
# 1  
Old 10-23-2009
Error while running as shell script

Storage_Unit=`du -h /var/spool/cron/root|awk '{print $1}'|sed -e "s/^.*\(.\)$/\1/"`
If [ $Storage_Unit = "G" ]
Size=`du -h /var/spool/cron/root|awk '{print $1}'|sed 's/.\{1\}$//'`
for Size_rounded_number in $(printf %.0f $Size); do
if [ $ROUNDED_Size -gt "10" ]      #setting a threshold of say 10G
cp /dev/null /var/spool/mail/root
echo "Size in $ROUNDED_Size
echo "storage unit in $Storage_Unit"

I am getting the following error while running the script:
Code: line 2: If: command not found line 3: syntax error near unexpected token `then' line 3: `then'

---------- Post updated at 05:12 PM ---------- Previous update was at 05:05 PM ----------

Worked it out. Their was a typo error:
If instead of if

Now getting another error:
Code: line 3: syntax error at line 12: `else' unexpected

# 2  
Old 10-23-2009
if [ $ROUNDED_Size -gt "10" ]; then      #setting a threshold of say 10G

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error while running Procedure in shell script

Hi All, I am running the below proc in unix by connecting through sqlplus and the procedure is completing successfully. But when i am trying to run through shell scripting by using function. I am getting the error as follows. Please guide me where I am going wrong. #!/bin/sh opera () {... (6 Replies)
Discussion started by: bhas85
6 Replies

2. Shell Programming and Scripting

Cp not working in shell script but running perfectly from shell

Dear All, I have script. Dest="" IFS=' ' for translation in $(echo $MY_MAP) do t1=$(echo $translation | cut -d"=" -f1) t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1) if then Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2 break; ... (4 Replies)
Discussion started by: yadavricky
4 Replies

3. Shell Programming and Scripting

Changing shell from a script and running something from the new shell

Hi We use "tcsh" shell . We do the following steps manually: > exec ssh-agent zsh > python "" (in the zsh shell) I am trying to do the steps above from a shell script This is what I have so far echo "Executing " exec ssh-agent zsh python "" exit 0 Problem is... (5 Replies)
Discussion started by: heman82
5 Replies

4. Solaris

Error during running sqlplus command from shell script in Solaris

I am using following code to connect to oracle database from solaris shell script. which will try thrice to connect the database the 4rth atempt it will exir=t. count=0 while ; do sqlplus -s $usrname/$password@dbSID <<-EOF | tee $logfile WHENEVER OSERROR EXIT 9; WHENEVER SQLERROR... (4 Replies)
Discussion started by: millan
4 Replies

5. Shell Programming and Scripting

Launcher Error: while running shell script

Hi Experts, I have a shell script which used to take oracle database backup, which is scheduled in a tidal scheduling tool. however it is throwing an error while triggering the job and getting below error in the log file. "Launcher Error: This is an internal function" shell script is... (1 Reply)
Discussion started by: UnniVKN
1 Replies

6. Shell Programming and Scripting

Shell script running command in different shell

Hi All, Is there any way where we can run few commands with different shell in a shell script ? Let's have an example below, My first line in script reads below, #!/bin/sh However due to some limitation of "/bin/sh" shell I wanted to use "/bin/bash" while executing few... (9 Replies)
Discussion started by: gr8_usk
9 Replies

7. Shell Programming and Scripting

error running shell script

how can i fix this error. + f_Delete resync-printers.ksh: test: argument expected lpadmin: Expected printer or class after '-x' option! resync-printers.ksh: test: argument expected + f_Create resync-printers.ksh: trying to execute a function (20 Replies)
Discussion started by: ggoliath
20 Replies

8. Shell Programming and Scripting

`(' unexpected error when running a shell script in AIX

Hi, We are moving from linux to AIX servers, and as a result testing our scripts on the new platform. When I run one of our scripts, I get the following error message: ./ syntax error at line 21 : `(' unexpected Following is an extract from the script: ...... ........ (1 Reply)
Discussion started by: dawgfather80
1 Replies

9. Solaris

Running from Shell Vs running from RC script

Hi, i have a script which need to do behave differently when run as a startup process from init.d/ rc2.d script and when run manually from shell. How do i distinguish whether my script is run by init process or by shell?? Will the command /proc/$$/psinfo | grep "myscript" work well???... (2 Replies)
Discussion started by: vickylife
2 Replies

10. Shell Programming and Scripting

error in running shell script in cron

#!/bin/bash CLASSPATH=. #CLASSPATH=${CLASSPATH}:${INSTALL_PATH}home/squidlog/ CLASSPATH=${CLASSPATH}:${INSTALL_PATH}usr/java/latest/lib/*.jar javac echo "CLASSPATH=$CLASSPATH" #home/wbiadmin/JRE1.4.2/j2re1.4.2_15/bin/java CopyFile /usr/bin/java... (3 Replies)
Discussion started by: sari
3 Replies
Login or Register to Ask a Question