VMware Cloud Community
BPL5000
Contributor
Contributor
Jump to solution

How do I copy a file from a web server to an ESX server

I have a file located at http://10.0.0.14/esxupdate/test.txt and I want to copy it to /home/scripts on my ESX server. I'm trying to do this from a putty session on my ESX server. I tried this...

cp http://10.0.0.14/esxupdate/test.txt

But that did not work. How can I copy this file to my ESX server?

0 Kudos
1 Solution

Accepted Solutions
Texiwill
Leadership
Leadership
Jump to solution

Hello,

All you should need to issue is:

lwp-download

There is no need to enable and disable port 80 going out. It is allowed by default.

Best regards,

Edward L. Haletky, author of the forthcoming 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', publishing January 2008, (c) 2008 Pearson Education.

--
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
14 Replies
admin
Immortal
Immortal
Jump to solution

Google for WinSCP or FastSCP. Both are free Windows utilities that will make it very easy to copy files from your Windows box to your ESX server and vise versa.

Chris

0 Kudos
BPL5000
Contributor
Contributor
Jump to solution

I already have and use WinSCP, but I would like to know how I can do this from the console so I can script it.

0 Kudos
Dave_Mishchenko
Immortal
Immortal
Jump to solution

With Linux you could use the get command but I don't think it is included with ESX. Could you use scp or ftp to get the file instead?

0 Kudos
admin
Immortal
Immortal
Jump to solution

Hello

You can use this command from the Virtual Console

      • from a perl script ***

use LWP::Simple;

`esxcfg-firewall -o 80,tcp,out,httpClient`;

getstore ("http://10.0.0.14/esxupdate/test.txt",'/tmp/test.txt');

`esxcfg-firewall -c 80,tcp,out,httpClient`;

      • from command line / batch ***

esxcfg-firewall -o 80,tcp,out,httpClient

perl -MLWP::Simple -e 'getstore "http://10.0.0.14/esxupdate/test.txt",'/tmp/test.txt'

esxcfg-firewall -c 80,tcp,out,httpClient

BPL5000
Contributor
Contributor
Jump to solution

jfrichard, that looks great, but when I run it from a file called test.script, I get this error:

# ./test.script

./test.script: line 2: unexpected EOF while looking for matching `''

./test.script: line 4: syntax error: unexpected end of file

Any ideas why I get this error?

Thanks,

BPL

0 Kudos
admin
Immortal
Immortal
Jump to solution

Hi

Can you attach the script.

Did you make the script executable?

0 Kudos
BPL5000
Contributor
Contributor
Jump to solution

Permissions on the file are set to 775 and the script is attached.

0 Kudos
admin
Immortal
Immortal
Jump to solution

Hello,

You need more steps to build and run a script

1. Make the script executable "chmod +x script_name"

2. You have to inser in your script the type at the first line (#!/usr/bin/perl -w or #!/bin/sh)

3. Before run those line in a script have you try to run from the command line directly in the console?

0 Kudos
admin
Immortal
Immortal
Jump to solution

Hello,

For you information, you may use proper extention for your script

Perl : script_name.pl

Shell : script_name.sh

Your format will work but it will be simple for you to identify the script language (type)

0 Kudos
BPL5000
Contributor
Contributor
Jump to solution

Thanks jfrichard! I'm new to scripts so let me try to understand this. I have a file called patch.script that contains the following:

esxcfg-firewall -allowOutgoing

esxupdate --noreboot -r http://10.0.0.15/esxupdate/11-30-06/ESX-1006511 update

esxcfg-firewall -blockOutgoing

I list all my updates in this file and it works well. Is this really a script file? I don't think I ran "chmod +x script_name" on this file. I think I just ran "chmod 775 script_name". When I launch it using ./patch.script, it works. Also, the commands you listed under "command line/batch", should I be able to type them at the console? The first command worked, but the second one (perl -MLWP::Simple -e 'getstore "http://10.0.0.14/esxupdate/test.txt",'/tmp/test.txt') left me at a ">" prompt. I'm not sure how to exit out and get back to the normal prompt.

0 Kudos
admin
Immortal
Immortal
Jump to solution

Hello

In that case the best way for you to patch you ESX by using a script will be to use a existing one... It will be more powerfull and easy for you to use.

I use a script from vmprofessional for my environment

Also Virtrix make one advailable

Good luck!

0 Kudos
BPL5000
Contributor
Contributor
Jump to solution

I'll take a close look at those links, but I'd still like to know how to copy this file over when connected with putty. In your following example...

esxcfg-firewall -o 80,tcp,out,httpClient

perl -MLWP::Simple -e 'getstore "http://10.0.0.14/esxupdate/test.txt",'/tmp/test.txt'

esxcfg-firewall -c 80,tcp,out,httpClient

Should this work if I type this in a putty session? The first command seems to work, but the second command does not... it brings me to a ">" prompt.

Thanks!

0 Kudos
Texiwill
Leadership
Leadership
Jump to solution

Hello,

All you should need to issue is:

lwp-download

There is no need to enable and disable port 80 going out. It is allowed by default.

Best regards,

Edward L. Haletky, author of the forthcoming 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', publishing January 2008, (c) 2008 Pearson Education.

--
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
BPL5000
Contributor
Contributor
Jump to solution

Edward, you are the man! That works awesome! Thank you, thank you, thank you! Looking forward to the release of your book!

0 Kudos