Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use urlscan in a non-interactive session #115

Closed
typoon opened this issue May 13, 2021 · 10 comments
Closed

Cannot use urlscan in a non-interactive session #115

typoon opened this issue May 13, 2021 · 10 comments

Comments

@typoon
Copy link

typoon commented May 13, 2021

When trying to use urlscan in a non-interactive session (via a tmux plugin or rofi) the following error is thrown:

Traceback (most recent call last):
  File "/home/gilgamesh/code/urlscan/bin/urlscan", line 191, in <module>
    main()
  File "/home/gilgamesh/code/urlscan/bin/urlscan", line 166, in main
    msg = process_input(args.message)
  File "/home/gilgamesh/code/urlscan/bin/urlscan", line 140, in process_input
    close_stdin()
  File "/home/gilgamesh/code/urlscan/bin/urlscan", line 100, in close_stdin
    fdesc = os.open('/dev/tty', os.O_RDONLY)
OSError: [Errno 6] No such device or address: '/dev/tty'

It can be reproduced by creating a script in your home directory like this:

#!/usr/bin/env bash

items=$(echo "https://www.google.com" | urlscan -d -n -c > /tmp/log.txt 2>&1)
echo $items

Run that script through rofi for example (or any way you have of running it non-interactively) and check the contents of /tmp/log.txt

I have written a fix for this issue that I will submit the PR in a few minutes.

typoon pushed a commit to typoon/urlscan that referenced this issue May 13, 2021
@Boruch-Baum
Copy link
Contributor

I don't understand how your example reproduces the error that you're reporting. I can and do use urlscan fine from a tmux plugin. Can you give an example of piping it into rofi? For your rofi case, I'm stuck not able to pipe any urls, but that's because I don't see an appropriate rofi "mode", not because of any error in urlscan.

More fundamentally, I don't understand why you're even trying to run urlscan non-interactively. The whole point of it is to be an interactive command! Any attempt to use urlscan non-interactively will have to perform "double-work" in parsing the urls out of the urlscan output because after urlscan itself parses the urls, it outputs much more than the raw urls. That's true even when option --compact is used.

@typoon
Copy link
Author

typoon commented May 28, 2021

It is not piping it through rofi, it is literally running it through rofi. Open rofi and type the whole path to your shellscript in it. You will be able to reproduce it like that.

The use case is passing the output of urlscan to fzf when being used from the context of a tmux plugin.

Try this plugin I created: https://github.com/typoon/tmux-urlscan-fzf

Without the patch I submitted it does not work, because urlscan is ran non-interactively.

Hopefully this clears things out. Let me know if it still does not make sense.

@Boruch-Baum
Copy link
Contributor

Boruch-Baum commented May 28, 2021 via email

@typoon
Copy link
Author

typoon commented May 28, 2021 via email

@Boruch-Baum
Copy link
Contributor

Boruch-Baum commented May 28, 2021 via email

@firecat53
Copy link
Owner

Thank you for the conversation! I promise I am following, although I have not had time to sit down and process it fully. I hopefully will have time soon!

@Boruch-Baum
Copy link
Contributor

Boruch-Baum commented May 28, 2021 via email

@typoon
Copy link
Author

typoon commented May 28, 2021 via email

@Boruch-Baum
Copy link
Contributor

Boruch-Baum commented May 28, 2021 via email

@firecat53
Copy link
Owner

I'll go ahead and merge the PR as it seems so far to have no negative side
effects. If it helps you get creative in using urlscan, I'm all for it! Thanks
to the both of you for the respectful conversation and ideas thrown around. This
is how open source should work!

firecat53 pushed a commit that referenced this issue Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants