VMware Cloud Community
The-Kevster
Contributor
Contributor
Jump to solution

Shell Script Problems With FTP inside IF

Hi,

Attatched is a simple script I produced to backup the etc folder to an FTP server. All works well except I'm now trying to add the option to upload the backup to a second FTP server.

The if statement work well EXCEPT for when the ftp statements is there. I get an unexpected end of file?

Any help would be appreciated.

Thanks!

Ok realised that your not allowed to indent the !EOF Now fixed, enjoy the file Smiley Happy

Message was edited by: The-Kevster

0 Kudos
1 Solution

Accepted Solutions
Texiwill
Leadership
Leadership
Jump to solution

Hello,

Change the following lines from

	ftp -n ${strFtp2_Server} << !EOF
	user ${strFtp2_Username} ${strFtp2_Password}
	put /tmp/${strFilename} ${strFtp2_Path}${strFilename}
	quit
	!EOF

to

	ftp -n ${strFtp2_Server} << !EOF
user ${strFtp2_Username} ${strFtp2_Password}
put /tmp/${strFilename} ${strFtp2_Path}${strFilename}
quit
!EOF

Note that you should NOT have any white space in front of the ftp commands or the !EOF line.


Best regards,

Edward L. Haletky

VMware Communities User Moderator

====

Author of the book 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', Copyright 2008 Pearson Education. CIO Virtualization Blog: http://www.cio.com/blog/index/topic/168354

As well as the Virtualization Wiki at http://www.astroarch.com/wiki/index.php/Virtualization

--
Edward L. Haletky
vExpert XIV: 2009-2023,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill

View solution in original post

0 Kudos
1 Reply
Texiwill
Leadership
Leadership
Jump to solution

Hello,

Change the following lines from

	ftp -n ${strFtp2_Server} << !EOF
	user ${strFtp2_Username} ${strFtp2_Password}
	put /tmp/${strFilename} ${strFtp2_Path}${strFilename}
	quit
	!EOF

to

	ftp -n ${strFtp2_Server} << !EOF
user ${strFtp2_Username} ${strFtp2_Password}
put /tmp/${strFilename} ${strFtp2_Path}${strFilename}
quit
!EOF

Note that you should NOT have any white space in front of the ftp commands or the !EOF line.


Best regards,

Edward L. Haletky

VMware Communities User Moderator

====

Author of the book 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', Copyright 2008 Pearson Education. CIO Virtualization Blog: http://www.cio.com/blog/index/topic/168354

As well as the Virtualization Wiki at http://www.astroarch.com/wiki/index.php/Virtualization

--
Edward L. Haletky
vExpert XIV: 2009-2023,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
0 Kudos