Reputation: 1252
I'm making a shell script and I want to know if it's possible to write directly to the command line when the script is executed ?
Example :
user@localhost:/home/user$./script.sh
... output
... another output
... another output
... last output
user@localhost:/home/user$I want to write here on the command line
I don't want to "echo" some text, I want to write directly at the prompt.
Thanks!
Upvotes: 1
Views: 4131
Reputation: 1
If you are using X environment install xclip
and xdotool
, then:
#!/bin/bash
your scripts....
echo -n your command to write 2>&1|xclip
xdotool click 2
Upvotes: 0
Reputation: 21628
In ksh:
print -s $(script)
will print to the command history. Wrap this in a function and you'll have something close to what you are asking for.
Upvotes: 0
Reputation: 4447
If you just want the text to show up there, but not be able to do anything with it, you can do this.
File test.sh:
echo "Output"
./test2.sh &
File test2.sh:
echo "Output2"
Notice how the first script calls the second script with the &
at the end.
In this case, "Output2" will be written to the prompt, but it can't be deleted and will have no effect on the next command at all. But if this is something you're doing to grab the user's attention, it would work.
Upvotes: 0
Reputation: 49344
No, you can't do that. If you want user to invoke your provided command after your script is finished - why not just prompt user for confirmation?
Upvotes: 5