Splunk Dev

Why did external search command exit unexpectedly with non-zero error code 1?

medveleyenet
New Member

Hi
I create a script whit python and i configure the commands.conf but appears the follow message: "External search command exited unexpectedly with non-zero error code 1"

commands.conf
[sshprueba8]
chunked = true
filename = sshprueba8.py

script

!/usr/bin/env python

-- coding: utf-8 --

import paramiko
import sys
import time
HOST = "172.16.10.100"
USER = "admin"
PASS = "admin"
ITERATION = 1

f = open ('/Documents/Archivo de prueba.txt','w')

def fn():
client1=paramiko.SSHClient()
client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client1.connect(HOST,username=USER,password=PASS)
stdin, stdout, stderr = client1.exec_command('show ip interface brief')
saveoutput = open("/Users/RicardoMedina/Documents/Archivo de prueba.txt", "a")
saveoutput.write(stdout.read())
print stdout.read()
fn()

Labels (1)
0 Karma

splunkoptimus
Path Finder
0 Karma

lguinn2
Legend

Does this script run properly when used independently of Splunk?
Does this script run properly when using the same account as Splunk?

Splunk has its own copy of python which it will use to execute scripts. Does the Splunk python have the libraries that you need?

Did you look at the search.log that was created when you tried to use this command?

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...