- From: Steven Danna <
>
- To: "
" <
>
- Cc: Bradford L Knowles <
>
- Subject: [chef] Re: Why am I getting this error from net-scp?
- Date: Wed, 26 Nov 2014 12:42:10 +0000
Hi,
As a quick followup, if you wanted to avoid shelling out, you could do
something like:
Dir.glob('/full/path/to/dir/*.xml').sort.last
Cheers,
Steven
On Wed, Nov 26, 2014 at 12:35 PM, Steven Danna
<
>
wrote:
>
Hi,
>
>
> source = cmd.stdout
>
>
My guess is your output has a newline attached to it. Since newlines
>
are valid characters in filenames, there is no reason for this to
>
raise an error before the file can't be found. Try:
>
>
source = cmd.stdout.chomp
>
>
Cheers,
>
>
Steven
>
>
On Wed, Nov 26, 2014 at 3:11 AM, Brad Knowles
>
<
>
>
wrote:
>
> Folks,
>
>
>
> So, I'm doing some compliance work for a customer (not PCI, but similar),
>
> and one thing we decided was to use scp to upload and download large files
>
> from a central fileserver. This way we don't have to worry about opening
>
> any more holes in firewalls (because ssh already has to be open), no
>
> additional Pandoras Boxes, etc....
>
>
>
> The download works fine. But when I'm trying to upload the results of the
>
> scan, it bombs out. The weird thing is that the code uses
>
> Mixlib::ShellOut to go find the file in question just a few lines above,
>
> but then Net:Scp craps out.
>
>
>
> A slice of logs showing the error message is at
>
> <http://pastebin.com/YXPu4TKS>.
>
>
>
> I haven't done the Windows side of the code yet, but the Linux part of the
>
> code for this section looks like this:
>
>
>
> if platform_family?("rhel")
>
> ruby_block 'find-and-upload-ciscat-results' do
>
> block do
>
> require 'mixlib/shellout'
>
> require 'net/scp'
>
> cmd = Mixlib::ShellOut.new("find #{resdir} -name '*.xml' |
>
> sort | tail -1")
>
> cmd.run_command
>
> cmd.error!
>
> source = cmd.stdout
>
> Chef::Log.debug("Uploading source file #{source} to
>
>
:#{target}")
>
> Net::SCP.upload!(host, user, source, target, :ssh => { :password =>
>
> pass })
>
> end
>
> end
>
>
>
> # elsif platform_family?("windows")
>
> end
>
>
>
>
>
> Am I doing something incredibly stupid here?
>
>
>
> --
>
> Brad Knowles
>
> <
>
>
> LinkedIn Profile: <http://tinyurl.com/y8kpxu>
>
>
Archive powered by MHonArc 2.6.16.