Score:0

Bash shell script calling an external program isn't displaying output to the current terminal

sa flag

I'm new to shell scripts. I'm making a headless raspberry pi that hacks WiFi networks (for educational purposes) with a program called wifite. The plan is for it to then send an email to with an attachment of the output (not implemented yet).

So this program is interactive so I have to send keyboard input I do that via xdotool. The main issue is that when I try to Ctrl+C after some time it sends the input to the current terminal on screen but wifite runs on the background and I get no output to the terminal.

Now that's fine I do not need onscreen output but I need to be able to send keyboard input to wifite somehow and i think the easiest way to is to force wifite to output to the current terminal so xdotool can send keyboard inputs. Here's the script:

#!/bin/sh
sleep 1m
`sudo wifite --kill | tee output.txt`
sleep 1m
`xdotool key ctrl+c`
`xdotool key Enter`

Let me know if there is anything I can do to make the script better. Perhaps i could use a more effective programs within the script. All help is greatly appreciated.

FedKad avatar
cn flag
Why are you using backticks in the `sudo` command? Why are you single-quoting the last two commands?
Hariss Gills avatar
sa flag
I read somewhere that backtics must be used when running external applications and the quotes are a formatting mistake sorry.
hr flag
@HarissGills you can use the [edit] button under your post to correct the formatting
Hariss Gills avatar
sa flag
@steeldriver thanks got that fixed now
Koen avatar
ca flag
https://unix.stackexchange.com/questions/48392/understanding-backtick/48393
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.