Sponsored Content
Top Forums Shell Programming and Scripting Freezes up execution of the script Post 302820383 by MJCreations on Wednesday 12th of June 2013 02:53:35 PM
Old 06-12-2013
Awk: syntax error near my file names

Im currently getting a list of rather odd errors. I've tried everything, but as someone mentioned I prob need to past the code.

i get errors saying

Code:
usage: ssh [blah blah
awk: (my file name).txt
awk:                    ^syntax error
awk: (my file name).txt
awk:                    ^syntax error


and it repeats for every file.
Code:
# Read file cred.txt (with one IP per line), connect to servers (one at a time), and download directory listing
i=1
param=$(sed -n "{$1}p" /etldata/dev1/cdm/parm/cdm_param.txt) #Get the last saved parameter in cdm_param.txt (Date in format YYYYMMDD when the script was last successfully run)
param=$(date -d $param +%Y-%m) # Convert YYYYMMDD to YYYY-DD
while read line; do
	host=$line
	ssh $user@$host ls -l $directory $src_file_name$param'*' > ftpList$i.txt
	awk -F '{print substr($line,length($line)-13,10)}' ftpList$i.txt > Dates$i.txt #Save the date part of each file name
															  #in the directory listing downloaded previously.
	awk -F '{print substr($line,length($line)-30,27)}' ftpList$i.txt > Files$i.txt	#Save the name of each file.
		linenum=0 #Auxiliary variable for sed. Will be used to match the line where the condition is satisfied with the corresponding file.
		
		while read list; do
		linenum=$((linenum+1))
		date_of_file=$(date -d "$list" +%Y%m%d) #Convert the modification datetime of each file to format YYYYMMDD
		    if [ "$date_of_file" -gt "$param" ] ; then #Compare with the last saved parameter
			file=$(sed -n "${linenum}p" Files$i.txt)	#If the condition is satisfied, use sed to get the name of the file
														#in the same line of Files$i.txt.
		while read line2; do	#Connect again and download file when the above condition has been satisfied.
			sftp $user@$host <<END_RETRIEVE
			cd $was7sourcedir
			get $file
			quit
END_RETRIEVE
		done < 'cred.txt'
mv $file  home/p79793/FTPtest/$file'-0'$i #Rename file with its original name and append '-01', '-02', and so on, after the # of each server.	
		    fi
		done < Dates$i.txt
#rm ftpList$i.txt Dates$i.txt Files$i.txt #Delete auxiliary files. 																		   # REFER TO FILE jessica4.pdf TO SEE WHERE YOU HAVE TO 
																		   																	 
	i=$((i+1)) #Go to the next server
linenum=0
done < 'cred.txt'
echo $(date +'%Y%m%d') > /etldata/dev1/cdm/parm/cdm_param.txt 
rm cred.txt								  
exit 0


Last edited by Scott; 06-12-2013 at 04:04 PM.. Reason: Added one more code tag
 

10 More Discussions You Might Find Interesting

1. SCO

Unixware 7.1.3 console freezes

I am using UnixWare 7.1.3 evaluation version and I have moved to network yesterday. I could able to ping and I tried to telnet to that server and i have user id,passwrd prompt then it was asking to buy the license . Today morning Console was frozen and I tried to reboot the server couple of times.... (0 Replies)
Discussion started by: visu101
0 Replies

2. Solaris

Solaris 10 freezes up while logging in.....!!!!

Hi all, I have installed Solaris along with Xp ....The installation was successful... I get the Grub menu displaying Solaris along with Win Xp....After i select Solaris the following happens, "Failed to initialize inband hotplug controller" The above message repeats three times & i get the... (2 Replies)
Discussion started by: codewarrior
2 Replies

3. UNIX for Dummies Questions & Answers

Fedora 7 freezes

Hi, Recently my Fedora running under level 3 begun freezing. It was running for about four months without any failures, but now it freezes almost every day, even twice a day. Sometimes it comes back itself, sometimes hard reboot is needed. This is a remote server where I connect through... (2 Replies)
Discussion started by: Georgy
2 Replies

4. Shell Programming and Scripting

Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test. The expect script is run... (2 Replies)
Discussion started by: twk
2 Replies

5. Gentoo

xorg constantly freezes

this is purely for posterity but it took me a while to find this solution online. 10.1 comes wanting to install the stable releases of xorg and the kernel. However on many platforms (especially with intel video) the result is an xorg that functions for a few minutes but then hangs up and prevents... (0 Replies)
Discussion started by: thmnetwork
0 Replies

6. Shell Programming and Scripting

AIX .ksh script freezes when using the mail -s command

Hello I am trying to send an email when a .KSH script is run on an AIX Machine. This email will only include a subject line that is made up of variables from within the script, and is as follows: CURRENT_DATE=`date +%Y%m%d` TIME=`date` ADMIN="myname@domain.com" date block () { ... (4 Replies)
Discussion started by: jimbojames
4 Replies

7. UNIX for Advanced & Expert Users

SSH using shell script terminates the script execution

Hello, I am writing a shell script in which i do ssh to remote server and count the number of files there and then exit. After the exit the shell script terminates which i believe is expected behavior. Can some one suggest me a way where even after the exit the script execution resumes. ... (2 Replies)
Discussion started by: manaankit
2 Replies

8. Emergency UNIX and Linux Support

invoke one script based on previous script execution

I am database guy and not very good at shell scripts. I am seeking help to sharp my script coding. I have 5 scripts 1. master script. I use this one to call other four scripts to do database work. 2. db_backup_1 and log_backup_1 3. db_backup_2 and log_backup_2 in master script, I want to... (4 Replies)
Discussion started by: duke0001
4 Replies

9. Red Hat

system freezes / hangs

Hi, We're using - openldap-2.3.43-12.el5_6.5 nss_ldap-253-25.el5 on RHEL-5.5 Intermittently the entire system hangs, no message is present in any of the log files, login to the system fails, ssh fails, ping fails, the only way to recover is to hard-boot the system. We consulted... (3 Replies)
Discussion started by: TheRock
3 Replies

10. Solaris

Script on Solaris spawning 2 processes for one shell script execution

Hi, I am having a shell script on Solaris 10 which has a while loop as shown below. #!/usr/bin/ksh # while do sleep 60 done Name of the shell script is coldcentric.sh. I executed script /DATAWAREHOUSE/LOAD/Scripts/coldcentric.sh from a command task in Informatica worklow as... (3 Replies)
Discussion started by: chekusi
3 Replies
ECACCESS-FILE-MOVE(1p)					User Contributed Perl Documentation				    ECACCESS-FILE-MOVE(1p)

NAME
ecaccess-file-move - Move or Rename ECaccess Files SYNOPSIS
ecaccess-file-move -version|-help|-manual ecaccess-file-move [-debug] source-ecaccess-file target-ecaccess-file DESCRIPTION
Allow moving an ECaccess File. When the move occurs within the same ECaccess File System then it is a rename. When the move occurs across two different ECaccess File Systems then first a copy is done and then a delete of the original file is done (e.g. similar to ecaccess- file-copy ... -erase). The source-ecaccess-file and target-ecaccess-file are in the form [domain:][/user-id/]path. Please read the "Shell commands -> File Management" section of the "ecaccess" guide for more information on the ECaccess File System. ARGUMENTS
source-ecaccess-file The source ECaccess File name. target-ecaccess-file The target ECaccess File name. OPTIONS
-version Display version number and exits. -help Print a brief help message and exits. -manual Prints the manual page and exits. -debug Display the SOAP messages exchanged. EXAMPLES
ecaccess-file-move ec:test1.txt ec:test2.txt Rename the test1.txt file in the ECFS directory of the authenticated user in test2.txt. ecaccess-file-move ec:test1.txt home:test2.txt Copy the test1.txt file from the ECFS directory of the authenticated user to the test2.txt file in the $HOME directory of the authenticated user, then delete the test1.txt file from ECFS. SEE ALSO
ecaccess-file-delete, ecaccess-file-get, ecaccess-file-mget, ecaccess-file-modtime, ecaccess-file-mput, ecaccess-file-rmdir, ecaccess-file- copy, ecaccess-file-dir, ecaccess-file-mdelete, ecaccess-file-mkdir, ecaccess-file-chmod, ecaccess-file-put, ecaccess-file-size and ecaccess. perl v5.14.2 2012-04-16 ECACCESS-FILE-MOVE(1p)
All times are GMT -4. The time now is 10:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy