Questions tagged [slurp]

For programming questions about reading a file fully in one operation rather than reading it one line at a time.

In Perl, slurp mode is activated by un-setting a special variable: $/ = undef; after which, reading from a file handle will read the entire file rather than the default of just one line from it.

There is also a File::Slurp Perl module that offers similar functionality of reading the entire contents of a file through a read_file method rather than messing around with magic variables.

Ansible has a similar concept with a built-in slurp module that fully reads files from remote nodes.

39 questions
2
votes
2 answers

Why is Yahoo! Slurp requesting /1338.aspx?

Ip: 67.195.112.247 Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp) System.Web.HttpException: The file '/1338.aspx' does not exist. IP : 67.195.112.247 Host : b3091104.crawl.yahoo.net Country:…
Chris S
  • 64,770
  • 52
  • 221
  • 239
2
votes
1 answer

Clojure: War Compilation Failure with Missing Data File Dependency

I am working on an webapp that relies on a certain data file to be slurped at runtime. Without the datafile present I don't seem to be able to compile. Why is this? This is in my core.clj (def my-data (slurp "my-file.txt")) Then when I try to…
David Williams
  • 8,388
  • 23
  • 83
  • 171
1
vote
2 answers

How to import JSON file from a remote host into Ansible variable?

I am using ansible.builtin.slurp to do this. Here is the relevant part of my Ansible role: - name: Load config slurp: src: "/etc/mlnx_snap/mlnx_snap.json" register: imported_config - name: Debug debug: var: imported_config I expect to…
Andy Mac
  • 157
  • 2
  • 12
1
vote
1 answer

How to specify the TLS ciphers when connecting to HTTPs servers in clojure

When I am using `slurp' to get the HTML page from "https://clojuredocs.org/clojure.core/slurp", I always get the Exception like: SSLHandshakeException Received fatal alert: handshake_failure sun.security.ssl.Alerts.getSSLException (Alerts.java:192)…
xiepan
  • 623
  • 4
  • 13
1
vote
2 answers

Using Perl to print multiple lines

This code grabs a keyword 'fun' from text files that I have and then prints the 20 characters before and after the keyword. However, I also want it to print the previous 2 lines and the next two lines, and I'm not sure how to do that. I wasn't sure…
1
vote
3 answers

'No such file or directory' even though I own the file and it has read permissions for everyone

I have a perl script on CentOS and am trying to read a file using File::Slurp: my $local_filelist = '~/filelist.log'; use File::Slurp; my @files = read_file($local_filelist); But I get the following error: Carp::croak('read_file \'~/filelist.log\'…
Kev
  • 15,899
  • 15
  • 79
  • 112
0
votes
1 answer

merge couple of objects together with jq slurp add without overwrite duplicate key

i have this two json files: ubuntubionic.json: { "ubuntu": { "os_ver": "bionic", "image": "abcdef", "image_tag": "3.33.3", "docker_compiler_image": "abc", "image_compiler_tag": "4.44.4" } } and…
0
votes
1 answer

Ansible - Define per host environment variable using slurp to read file on remote host

I am working on an ansible script where I want to read a file on each host and set an environment variable for that host based on some text in that file. And I need that environment variable to be available during the entire playbook execution on…
adbdkb
  • 1,897
  • 6
  • 37
  • 66
0
votes
1 answer

How to set the remote host using slurp in Ansible?

I would like to read a remote file content in an Ansible playbook. - name: Load spark defaults slurp: src: /etc/spark/conf/spark-defaults.conf register: spark_defaults - debug: msg: "{{ spark_defaults['content'] | b64decode }}" I have…
Noam Shaish
  • 1,613
  • 2
  • 16
  • 37
0
votes
2 answers

Clojure slurp Connection refused

I've created a project using Luminus with the following command: lein new luminus myapp +mysql +kee-frame +swagger +oauth +kibit In this project I created an API call that calls a function to read a file from disk. The API Call (partly): {:get…
0
votes
1 answer

Write slurped variable to a remote file in Ansible

I'm trying to figure out how one would copy or write the contents of a slurped variable to a remote (preferable) file. If this is not possible, what's the cleanest way to do it in steps? I have something like this: - name: Load r user public key …
0
votes
1 answer

Ansible: output file in locahost and register it as variable

I am trying to create a playbook where the created certs should be added as variable to create templates from it. The created certs are of *.pem format and resides in ansible localhost. I need to cat these files and load the contents as variable…
yog raj
  • 147
  • 2
  • 10
0
votes
1 answer

Ansible: Adding values to variable in a loop

I'm working on a playbook that does the following: Goes into a specified path on each Windows server Slurps text from a file and adds it to a variable Performs a check on the variable to see if a string of text exists Writes the results to a file…
0
votes
1 answer

Ansible slurp as private key in jenkins credential api error for json parsing?

I have jenkins setup, now I want to add node to jenkins, I am following the steps in How-to-Connect-to-Remote-SSH-Slaves. There is step to create credential with slave node private key. I try to create that using jenkins api by ansible. Tasks in…
Nilesh
  • 20,521
  • 16
  • 92
  • 148
0
votes
1 answer

slurp/csv/loop a file to create a list of dictionaries

I have a large file (1.6 gigs) with millions of rows that has columns delimited with: [||] I have tried to use the csv module but it says I can only use a single character as a delimiter. So Here is what I have: fileHandle = open('test.txt', 'r',…
sniperd
  • 5,124
  • 6
  • 28
  • 44