View previous topic :: View next topic |
Author |
Message |
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Wed Jun 28, 2023 2:00 pm Post subject: [solved] howto send command to start mprime calculation? |
|
|
Hi there,
I don´t want to manually tell mprime/prime95 to start the calculation. ATM I have to start the software (console) then press 4 as soon as the menu appears to start/restart the calculation.
So far I tried using pipes: Code: | echo 4 | ./mprime -d -m | and also Code: | xdotool key 4 | ./mprime -d -m | as well as Code: | xdotool key 4 enter | ./mprime -d -m | all of the afore mentioned commands don´t work to my content.
Also starting mprime then using && operator and simulating a keystroke wont work, since one had to exit mprime in order to start the second command.
Any ideas ? _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE
Last edited by Mgiese on Sun Jul 02, 2023 1:53 pm; edited 1 time in total |
|
Back to top |
|
|
proteusx Guru
Joined: 21 Jan 2008 Posts: 338
|
Posted: Thu Jun 29, 2023 6:05 am Post subject: |
|
|
Code: | xdotool type "./mprime -d -m"; xdotool key Return; xdotool key 4 |
or
Code: | xdotool type "./mprime -d -m"; xdotool sleep 0.3; xdotool key Return; xdotool key 4 |
|
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Thu Jun 29, 2023 9:16 am Post subject: |
|
|
proteusx wrote: | Code: | xdotool type "./mprime -d -m"; xdotool key Return; xdotool key 4 |
or
Code: | xdotool type "./mprime -d -m"; xdotool sleep 0.3; xdotool key Return; xdotool key 4 |
|
that (both code fragments) does not work. it starts mprime and thats it _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE |
|
Back to top |
|
|
ts-plus n00b
Joined: 04 Dec 2012 Posts: 26 Location: Germany
|
Posted: Thu Jun 29, 2023 9:56 am Post subject: |
|
|
What about configuring it manually only once and then start it without the "-m" switch? |
|
Back to top |
|
|
proteusx Guru
Joined: 21 Jan 2008 Posts: 338
|
Posted: Thu Jun 29, 2023 12:18 pm Post subject: |
|
|
Mgiese wrote: | that (both code fragments) does not work. it starts mprime and thats it |
Needs one more "sleep" and a "Return" at the end.
Code: | xdotool type "./mprime -d -m"; xdotool sleep 0.3; xdotool key Return; xdotool sleep 0.3; xdotool key 4; xdotool key Return |
Better to do it with a script:
Code: | #!/usr/bin/xdotool
type "./mprime"
sleep 0.3
key Return
key 4
sleep 0.3
key Return
# uncomment these if it asks for "Worker to start"
# sleep 0.3
# key Return |
|
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Fri Jun 30, 2023 11:10 am Post subject: |
|
|
Thank you, your script as well as your code works.
I am getting crazy here though. Whenever I want to run your script outside the mprime dir, it does not find the binary or the subcommands anymore Code: | bash: ./mprime: No such file or directory
user@pc ~ $ 4
bash: 4: command not found | I tried various things. Changing with "cd" into the directory does not work either, although I checked with "pwd" that I am actually in the desired directory..
Thanks for hints
PS : I need to start the script in a Terminal (that stays open) at User Logon. _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE |
|
Back to top |
|
|
ts-plus n00b
Joined: 04 Dec 2012 Posts: 26 Location: Germany
|
Posted: Fri Jun 30, 2023 11:51 am Post subject: |
|
|
You'd need to add the absolute path of mprime to the first type command of the xdotool script:
Code: | #!/usr/bin/xdotool
type "/opt/mprime/mprime"
sleep 0.3
...
|
|
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Fri Jun 30, 2023 12:07 pm Post subject: |
|
|
ts-plus wrote: | You'd need to add the absolute path of mprime to the first type command of the xdotool script:
Code: | #!/usr/bin/xdotool
type "/opt/mprime/mprime"
sleep 0.3
...
|
|
I tried that. Does not help _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE |
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Fri Jun 30, 2023 12:13 pm Post subject: |
|
|
I tried this now, but it also fails :
Code: | $ konsole --workdir /home/user/number -e "./command" | where command (located /home/user/command) contains the following (in the afore mentioned directory working) commands :
Code: | xdotool type "./mprime -d -m"; xdotool sleep 0.3; xdotool key Return; xdotool sleep 0.3; xdotool key 4; xdotool key Return |
this is the error :
Code: |
Warning: Could not start program '/home/user/number/command' with arguments ''.
Warning: execve: Exec format error
|
I also put /bin/bash in front of ./command, which just opens and closes the terminal without any error message _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE
Last edited by Mgiese on Fri Jun 30, 2023 9:08 pm; edited 2 times in total |
|
Back to top |
|
|
proteusx Guru
Joined: 21 Jan 2008 Posts: 338
|
Posted: Fri Jun 30, 2023 12:23 pm Post subject: |
|
|
Try this, but replace "~/tmp/prime95/" with your own prime95 directory. Code: | #!/usr/bin/xdotool
type "~/tmp/prime95/mprime"
sleep 0.3
key Return
key 4
sleep 0.3
key Return
sleep 0.3
key Return
|
|
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Fri Jun 30, 2023 12:24 pm Post subject: |
|
|
Code: | /bin/bash command.sh | in itself also does work
but Code: | konsole -e "/bin/bash ./command.sh" | does not, it just opens the konsole and closes it _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE |
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Fri Jun 30, 2023 1:14 pm Post subject: |
|
|
I figured something out that works for me (although a bit weird)
in ~/.config/autostart I had : Code: |
$ cat prime.desktop
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=primeALT
Comment=prime
Exec=konsole -e "/bin/bash start"
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false
| This started a konsole with mprime but without starting any calculation.
I manually created : Code: |
$ cat test.desktop
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=prime-neu
Comment=prime-manuel
Exec=./mprimedir/test1.sh
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false |
where test1.sh contains the following : Code: | #!/usr/bin/xdotool
type "~/mprimedir/mprime -d -m"
sleep 0.3
key Return
sleep 0.3
key 4
sleep 0.3
key Return
# uncomment these if it asks for "Worker to start"
# sleep 0.3
# key Return |
please neglect the 2 cat commands (I am tired).
For me it looks like, as if the first command starts the konsole with mprime in it and the second command executs that xdotool command in the window of the first command. Frankly, I don´t mind as long as it works and IT DOES
Since I was confused by this behaviour I disabled prime.desktop( which only starts mprime in a konsole) and indeed the test.desktop is useless in itself and does nothing (not even opening a konsole) but combining these 2 lead to the desired condition _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE |
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Fri Jun 30, 2023 10:54 pm Post subject: |
|
|
Mgiese wrote: | I figured something out that works for me (although a bit weird)
in ~/.config/autostart I had : Code: |
$ cat prime.desktop
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=primeALT
Comment=prime
Exec=konsole -e "/bin/bash start"
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false
| This started a konsole with mprime but without starting any calculation.
I manually created : Code: |
$ cat test.desktop
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=prime-neu
Comment=prime-manuel
Exec=./mprimedir/test1.sh
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false |
where test1.sh contains the following : Code: | #!/usr/bin/xdotool
type "~/mprimedir/mprime -d -m"
sleep 0.3
key Return
sleep 0.3
key 4
sleep 0.3
key Return
# uncomment these if it asks for "Worker to start"
# sleep 0.3
# key Return |
please neglect the 2 cat commands (I am tired).
For me it looks like, as if the first command starts the konsole with mprime in it and the second command executs that xdotool command in the window of the first command. Frankly, I don´t mind as long as it works and IT DOES
Since I was confused by this behaviour I disabled prime.desktop( which only starts mprime in a konsole) and indeed the test.desktop is useless in itself and does nothing (not even opening a konsole) but combining these 2 lead to the desired condition |
EDIT : that worked as long as i only logged in and out. when doing a real restart one timing flaw appeared. i had to add an extra "sleep 3" at the beginning to the test1.sh script. obviously the prime.desktop and test.desktop are being started simultaneously and the test.desktop could not execute as desired due to a not yet loaded instance of mprime. _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3140
|
Posted: Fri Jun 30, 2023 11:16 pm Post subject: |
|
|
Wait, why do you even use xdotool?
This thing you're trying to run is a command-line program, right? Is there any problem with its interface?
Doesn't it have batch mode, where you provide everything as arguments?
If it really requires standard input, can't you solve it with a simple redirection? You mentioned that pipe didn't work, but you didn't say why. Is there a delay or something?
{ sleep 1; echo stdinput; } | application
Though really, things like
Code: | /path/to/application << eof
multiline text
to be redirected
to stdin
eof |
should work |
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Fri Jun 30, 2023 11:23 pm Post subject: |
|
|
szatox wrote: | Wait, why do you even use xdotool?
This thing you're trying to run is a command-line program, right? Is there any problem with its interface?
Doesn't it have batch mode, where you provide everything as arguments?
If it really requires standard input, can't you solve it with a simple redirection? You mentioned that pipe didn't work, but you didn't say why. Is there a delay or something?
{ sleep 1; echo stdinput; } | application
Though really, things like
Code: | /path/to/application << eof
multiline text
to be redirected
to stdin
eof |
should work |
i like the idea of doing it easier than i do now and the educational aspect of it. though i don´t understand some of the things in your example script :
what does "<< eof" ?
i guess the single "eof" closes me putting things in std input ?
and i guess these "multiline text, to be redirected, to stdin" are example commands like pressing the number 4, for menupoint 4 for instance ?
i dont know if mprime has a batch mode and if there is something wrong with its interface, though i guess not. _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3140
|
Posted: Fri Jun 30, 2023 11:54 pm Post subject: |
|
|
there are several redirection operators in shell.
< filename
<< terminator_string_for_multiline_input
<<< "one line input string"
try them and see, handy stuff when scripting.
Quote: | like pressing the number 4, for menupoint 4 for instance | yeah, though now that I read it, "menupoint number 4" suggests a problem to me.
Does it use ncurses, commander, or other similarly advanced interface? Like in: it runs in a terminal, but acts kinda like gui, responding to events (e.g. button pressed) rather than input text?
For example there is an obvious difference in the way fdisk or gdisk (or just sh) ingest input. Even though fdisk is a human-interactive, you can just inject commands from a file and it will happily obey. Top wouldn't even start. |
|
Back to top |
|
|
ts-plus n00b
Joined: 04 Dec 2012 Posts: 26 Location: Germany
|
Posted: Sat Jul 01, 2023 8:23 am Post subject: |
|
|
ts-plus wrote: | What about configuring it manually only once and then start it without the "-m" switch? |
I'd like to point out (again), that propably the easiest solution to your problem would be to call "mprime -d". As the -m switch stands for "menu", there is no need to interact in any way and it will simply start. |
|
Back to top |
|
|
Mgiese Veteran
Joined: 23 Mar 2005 Posts: 1609 Location: indiana
|
Posted: Sat Jul 01, 2023 9:52 am Post subject: |
|
|
ts-plus wrote: | ts-plus wrote: | What about configuring it manually only once and then start it without the "-m" switch? |
I'd like to point out (again), that propably the easiest solution to your problem would be to call "mprime -d". As the -m switch stands for "menu", there is no need to interact in any way and it will simply start. |
i read you comment and just forgot to answer i would like to see the the occasional output (timings and eta) so it´s not of much use. in general i like to tinker a bit with things to educate myself. the harder the better
thank you anyways _________________ I do not have a Superman complex, for I am God not Superman
Ryzen9 7950x ; Geforce1650 ; kernel 6.5 ; XFCE |
|
Back to top |
|
|
ts-plus n00b
Joined: 04 Dec 2012 Posts: 26 Location: Germany
|
Posted: Sat Jul 01, 2023 11:27 am Post subject: |
|
|
And that is imho what the -d switch is for.
Code: | ./mprime -h
Usage: mprime [-bcdhmstv] [-aN] [-wDIR] [-pPIDFILE]
-b Run a predefined throughput benchmark, then exit.
-c Contact the PrimeNet server, then exit.
-d Print detailed information to stdout.
-h Print this.
-m Menu to configure mprime.
-s Display status.
-t Run the torture test.
-v Print the version number.
-aN Use an alternate set of INI and output files (obsolete).
-wDIR Run from a different working directory.
-pPIDFILE Filename for the PID file. Default is mprime.pid.
|
So the following should work:
Call "mprime -d -m" to configure it once (it will create the prime.txt config). After that you can always use "mprime -d" to start it (and get the detailed info). When starting mprime from another directory you might add -w<yourfirst-cwd> to let mprime find your config. |
|
Back to top |
|
|
|