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
dos2unix(1)						      General Commands Manual						       dos2unix(1)

NAME
dos2unix - DOS/MAC to UNIX text file format converter SYNOPSYS
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...] Options: [-hkqV] [--help] [--keepdate] [--quiet] [--version] DESCRIPTION
This manual page documents dos2unix, the program that converts plain text files in DOS/MAC format to UNIX format. OPTIONS
The following options are available: -h --help Print online help. -k --keepdate Keep the date stamp of output file same as input file. -q --quiet Quiet mode. Suppress all warning and messages. -V --version Prints version information. -c --convmode convmode Sets conversion mode. Simulates dos2unix under SunOS. -o --oldfile file ... Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used. -n --newfile infile outfile ... New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files. EXAMPLES
Get input from stdin and write output to stdout. dos2unix Convert and replace a.txt. Convert and replace b.txt. dos2unix a.txt b.txt dos2unix -o a.txt b.txt Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix ascii format. dos2unix a.txt -c iso b.txt dos2unix -c ascii a.txt -c iso b.txt dos2unix -c mac a.txt b.txt Convert and replace a.txt while keeping original date stamp. dos2unix -k a.txt dos2unix -k -o a.txt Convert a.txt and write to e.txt. dos2unix -n a.txt e.txt Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt. dos2unix -k -n a.txt e.txt Convert and replace a.txt. Convert b.txt and write to e.txt. dos2unix a.txt -n b.txt e.txt dos2unix -o a.txt -n b.txt e.txt Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt. dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt DIAGNOSTICS
BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me. AUTHORS
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (mac2unix mode) <wuebben@kde.org> MISCELLANY
Tested environment: Linux 1.2.0 with GNU C 2.5.8 SunOS 4.1.3 with GNU C 2.6.3 MS-DOS 6.20 with Borland C++ 4.02 Suggestions and bug reports are welcome. SEE ALSO
unix2dos(1) mac2unix(1) 1995.03.31 dos2unix v3.0 dos2unix(1)
All times are GMT -4. The time now is 11:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy