GithubHelp home page GithubHelp logo

Comments (17)

vaygr avatar vaygr commented on May 28, 2024 1

Thanks a lot! I also submitted an AUR package and will keep maintaining it. Hopefully that'll increase popularity of this useful tool.

from sexpect.

clarkwang avatar clarkwang commented on May 28, 2024

For now send -file only accepts a regular file. send sets a limit and at most 1024 bytes can be sent so it need to check the file size before reading. It cannot get the file size of a named pipe.

What's the benefit of using a named pipe in your use case?

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

Same as in the link in the description. I want to be able to pass <(dmenu -P) as an argument.

from sexpect.

clarkwang avatar clarkwang commented on May 28, 2024

OK. Let me see if I can remove the regular file check.

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

Another useful (somewhat related) thing would be to allow specifying - for -file to accept data from stdin. In both cases (named pipe and stdin) the 1024b limit can still be preserved, discarding everything else beyond that.

from sexpect.

clarkwang avatar clarkwang commented on May 28, 2024

May be like this:

  • send -file FILE [-limit COUNT]
    • FILE can be - which means stdin.
    • If -limit COUNT is not specified, FILE must be a regular file of size ≤ 1024.
    • COUNT in range [1, 1024].
  • send -fd FD -limit COUNT
    • -limit must be specified with -fd.
    • COUNT in range [1, 1024].

The idea is to make the behavior more explicit rather than silently discarding data so users would not be surprised.

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

Yeah, I think that's great.

from sexpect.

clarkwang avatar clarkwang commented on May 28, 2024

It's now available on the "devel" branch. Will merge to "master" after the doc is updated and tests are added.

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

That's impressive, thanks! Testing it now:

$ ./sexpect -s /tmp/sp.sock send -fd <(dmenu) -limit 32
[ERROR] invalid number: /dev/fd/63

Probably makes sense to accept paths as well, not just fd by number?

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

When I'm trying to use stdio, I have to hit extra Enter to make dmenu pop up:

./sexpect -s /tmp/sp.sock send -file - -limit 32 | dmenu

from sexpect.

clarkwang avatar clarkwang commented on May 28, 2024

That's impressive, thanks! Testing it now:

$ ./sexpect -s /tmp/sp.sock send -fd <(dmenu) -limit 32
[ERROR] invalid number: /dev/fd/63

Probably makes sense to accept paths as well, not just fd by number?

Shell's <(cmd) is not a FD. It's a pathname, as is /dev/fd/63 in the error message.

from sexpect.

clarkwang avatar clarkwang commented on May 28, 2024

When I'm trying to use stdio, I have to hit extra Enter to make dmenu pop up:

./sexpect -s /tmp/sp.sock send -file - -limit 32 | dmenu

sexpect's send sub-command is not supposed to output any meaningful data. It makes little sense to pipe the output to another command. According to your previous comments, you may want this:

./sexpect -s /tmp/sp.sock send -file <(dmenu) -limit 32
# OR
./sexpect -s /tmp/sp.sock send -fd 0 -limit 32 < <(dmenu)
# OR 
dmenu | ./sexpect -s /tmp/sp.sock send -fd 0 -limit 32

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

Shell's <(cmd) is not a FD. It's a pathname, as is /dev/fd/63 in the error message.

Yeah, this is what I'm saying. Maybe accept FD paths as well here?

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

sexpect's send sub-command is not supposed to output any meaningful data. It makes little sense to pipe the output to another command. According to your previous comments, you may want this:

./sexpect -s /tmp/sp.sock send -file <(dmenu) -limit 32
# OR
./sexpect -s /tmp/sp.sock send -fd 0 -limit 32 < <(dmenu)
# OR 
dmenu | ./sexpect -s /tmp/sp.sock send -fd 0 -limit 32

Yeah, sorry, I mismatched the commands. This worked:

$ dmenu <&- | ./sexpect -s /tmp/sp.sock send -cr -file - -limit 32

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

Shell's <(cmd) is not a FD. It's a pathname, as is /dev/fd/63 in the error message.

Yeah, this is what I'm saying. Maybe accept FD paths as well here?

Ignore this. Given that you removed regular file check, as you said in your previous comment -file works perfectly with a path:

$ ./sexpect -s /tmp/sp.sock send -file <(dmenu) -cr -limit 32

from sexpect.

vaygr avatar vaygr commented on May 28, 2024

Yep, see my previous comment. I think all is good now and works as expected designed.

from sexpect.

clarkwang avatar clarkwang commented on May 28, 2024

Merged to master: https://github.com/clarkwang/sexpect/releases/tag/v2.3.12

from sexpect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.