The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
I need help with arrays in C Shell domain Shell Programming and Scripting 5 11-19-2008 08:17 AM
Korn Shell Script to find out error in logfile jithu Shell Programming and Scripting 2 04-24-2008 02:12 PM
how to use arrays in c shell hgphsf Shell Programming and Scripting 6 12-14-2007 02:03 PM
Error Handling in Korn Shell scripts bhgopi UNIX for Advanced & Expert Users 4 09-06-2005 06:44 PM
korn shell "loops & arrays" muzica Shell Programming and Scripting 7 09-23-2004 03:02 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-21-2008
guruparan18 guruparan18 is offline
Registered User
  
 

Join Date: May 2008
Location: India
Posts: 37
Question Error with korn shell - arrays

Hi All

I have a FTP script which FTPs few files into an user folder. I intend to keep track of the folder size before FTP and after FTP and print that once the FTP script is run (a kind of comparison, "Before FTP, "After FTP").

I decided to use kron shells to accomplish this.
Code:
#! /bin/ksh

analyse_folders_pre() {

 # List of directories to check.
 dirNames[0]='bin'
 dirPath[0]='/home/user1/bin'
 dirNoFilesPre[0]=$(ls  ${dirPath[0]} | wc -l | awk '{print $1}')

 idx=0
 while [ $idx -ne 1 ]
 do
    tempSize=0
    dirFileSizePre[$idx]=0
    dirSize=0

    for i in $(ls ${dirPath[0]})
    do
      tempSize=$( ls -l $i | awk '{print $5}')
      ((dirSize=dirSize+tempSize))
    done
    dirFileSizePre[$idx]=$dirSize
    ((idx = idx+1))
 done

} ### End of analyse_pack_rel_pre

 ### Main Script Starts here ###
 # List of directories to check.
 dirNames[0]='bin'
 export dirNames

 dirPath[0]=''
 export dirPath

 dirNoFilesPre[0]=0
 export  dirNoFilesPre

 dirNoFilesPost[0]=0
 export  dirNoFilesPost

 analyse_folders_pre 

 ### Script to FTP
 ftp_files

 analyse_folders_post

 i=0
 while [ $i -ne 1 ]
 do
  echo ${dirNoFilesPre[$i]}
  echo ${dirFileSizePre[$i]}

  echo ${dirNoFilesPost[$i]}
  echo ${dirFileSizePost[$i]}
  ((i=i+1))
 done
But, I am getting the following error.
syntax error at line 8: `dirNoFilesPre[0]=$' unexpected

What might be wrong? Is there any better way to do it?
  #2 (permalink)  
Old 08-21-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
Quote:
dirNoFilesPre[0]=$(ls ${dirPath[0]} | wc -l | awk '{print $1}')

try doing this..

Quote:
dirNoFilesPre[0]=$(`ls ${dirPath[0]} | wc -l | awk '{print $1}'`)
  #3 (permalink)  
Old 08-21-2008
guruparan18 guruparan18 is offline
Registered User
  
 

Join Date: May 2008
Location: India
Posts: 37
Same error

Still getting the same error. . .
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0