Help needed to Spawn Shell on Python and Continue Execution


 
Thread Tools Search this Thread
Top Forums Programming Help needed to Spawn Shell on Python and Continue Execution
# 1  
Old 11-11-2017
Help needed to Spawn Shell on Python and Continue Execution

Code:
       def gob(url):
    print "\n\t[!] Running gobuster on target."
    params = " -e -s '307,200,204,301,302' -t 20 -u " + url + " >> /tmp/%s/gobuster.txt" % (ip)
               os.system("xterm -e bash -c "tail -f /tmp/%/gobuster.txt"")    
     for i in bflist:
            dirbf = "gobuster -w " + i + params
            print "Syntax: " + dirbf
            os.system(dirbf)

Hi there,

For this piece of code; I need it to be able to run.
2ndly, I need to code to execute in the foreground and continue execution of the remaining code line.
Code:
  os.system("xterm -e bash -c "tail -f /tmp/%/gobuster.txt"")

# 2  
Old 11-11-2017
Try:
Code:
  os.system("xterm -e bash -c \"tail -f /tmp/%/gobuster.txt\"")

and let us know what happens.
# 3  
Old 11-11-2017
The shell does not spawn after I tried.
# 4  
Old 11-12-2017
Quote:
Originally Posted by alvinoo
The shell does not spawn after I tried.
Well that is a useful reply - NOT!

If it is imperative to use 'xterm' then why not put your single line as a tiny script and call it something like:-
1) The script, say myscript.sh...
Code:
#!/bin/bash
tail -f /tmp/%/gobuster.txt
exit

2) And if you want python NOT to wait for it to finish; then...
Code:
os.system("xterm -e /your/path/to/myscript.sh &")

3) Or if you DO want python to wait for it to finish; then...
Code:
os.system("xterm -e /your/path/to/myscript.sh")

EDIT:
All this assumes you have imported 'os' into your python script...

Last edited by wisecracker; 11-12-2017 at 02:36 PM.. Reason: See EDIT above...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python Thread Execution Issue . . .

Greetings! I set up a basic threading specimen which does the job:#!/usr/bin/python import threading class a(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print("thread a finished") class b(threading.Thread): ... (0 Replies)
Discussion started by: LinQ
0 Replies

2. Shell Programming and Scripting

Continue Execution Based On List

Hi all. I have a script like this function check_filesize { filesize_1="$(ls -la "$1"|awk '{ print $5 }')" sleep 123 filesize_2="$(ls -la "$1"|awk '{ print $5 }')" if then echo "OK" else echo "NOT OK" sleep 1234 check_filesize $1 fi } function check_TR { chk="$(tail -1 $1|grep... (5 Replies)
Discussion started by: aimy
5 Replies

3. Shell Programming and Scripting

Help with spawn.. newbie to shell

Hi, I have a problem with the spawn execution with expect.. i have done the code for expect in a separate file and i am calling the this execution from the bash script.. as given below.. -bash-4.1$ cat main.sh #!/usr/bin/bash ./spawn.exp ========================== -bash-4.1$ cat... (2 Replies)
Discussion started by: satishkumar432
2 Replies

4. Shell Programming and Scripting

Spawn snmptrap from python

Hi I am trying to spawn an snmptrap from python but i keep getting the following error Invalid version specified after -v flag: 2c -c public 192.168.2.162 SNMPv2-SMI::enterprises.3.1.1 here is the python code i am using from subprocess import Popen Popen() When i test the same... (0 Replies)
Discussion started by: kaf3773
0 Replies

5. Shell Programming and Scripting

how to continue shell script execution process without control going to pompt?

Hi Friends, Iam invoking another shell script to create B2k_session_id from my shell script.It is properly creating B2k_session_id and after creation control is coming out from the script and going to command prompt.The lines which are after the exectrusteduser.com sh.com are not executing..may... (5 Replies)
Discussion started by: vadlamudy
5 Replies

6. Programming

Python Execution Stack

I was wondering if Python's execution stack does not grow if we make recursive call of a function i.e. if we implement a fibonacci () and factorial () functions and made recursive call of them in a conditional statement the execution stack will not grow? I wish someone answer this question with... (1 Reply)
Discussion started by: pharaoh
1 Replies

7. UNIX for Dummies Questions & Answers

UNIX command to skip any warning messages and continue job execution

Hello All, Good day! This is my first UNIX post. :D Anyways, I would like to seek help from you guys if you know of any UNIX command that will skip a warning message once it is encountered but continue to run the execution. Ok here's the situation in general: An encypted file is sent to... (2 Replies)
Discussion started by: jennah_rekka
2 Replies

8. Shell Programming and Scripting

shell script for getting pid of spawn processes from shell

Hi, I am new this forum. I request you peoples help in understanding and finding some solution to my problem. Here it goes: I need to perform this set of actions by writing a shell script. I need to read a config file for the bunch of processes to execute. I need to fecth the pid of... (4 Replies)
Discussion started by: sachin4sachi
4 Replies

9. Shell Programming and Scripting

perl - understand process status and continue the code execution

Hello, I need advice on how to check if started processes are finished in perl, here's explanation : OS is RHEL 4, perl -v = "This is perl, v5.8.0 built for i386-linux-thread-multi" The logic of the script : #!/usr/bin/perl use warnings; $param1 = $ARGV; $param2 = $ARGV; $param3 =... (2 Replies)
Discussion started by: sysgate
2 Replies

10. Shell Programming and Scripting

KORN Shell - Spawn new shell with commands

I want to be able to run a script on one server, that will spawn another shell which runs some commands on another server.. I have seen some code that may help - but I cant get it working as below: spawn /usr/bin/ksh send "telnet x <port_no>\r" expect "Enter command: " send "LOGIN:x:x;... (2 Replies)
Discussion started by: frustrated1
2 Replies
Login or Register to Ask a Question