DO NOT DEAL WITH THIS MEMBER
Hello.
When I write a script like "ping google.com" and double click on it then the window opened and closed. How can I keep it open and see the result?
Thanks.
Jun 2, 2019 03:18 AM
(This post was last modified: Jun 2, 2019 05:01 AM by Deathbox.)
Open command prompt or linux terminal and type
If it's a shell script:
Code #!/usr/bin/env
ping google.co.uk
sleep 3
Windows Batch/CMD script (.cmd/.bat):
Code ping google.co.uk
pause
Pink Floyd is one of my many addictions. I'm sorry but I'm a free member and thus, I cannot give rep back to you kind folk who have blessed me with your presence.
My howto on Arch servers on ARM devices (samba/dynamicdns/staticip/vncserver/ssh)
https://goo.gl/DgMvRt
DO NOT DEAL WITH THIS MEMBER
(Jun 2, 2019 03:18 AM)Deathbox Wrote: Open command prompt or linux terminal and type
If it's a shell script:
Code #!/usr/bin/env
ping google.co.uk
sleep 3
Windows Batch/CMD script (.cmd/.bat):
Code ping google.co.uk
pause
Thanks.
Why "sleep 3"? I like to see the result until I canceled it.
(Jun 3, 2019 05:32 AM)hack3rcon Wrote: Thanks.
Why "sleep 3"? I like to see the result until I canceled it.
That's for a Shell script.
Jun 3, 2019 07:40 AM
(This post was last modified: Jun 3, 2019 07:46 AM by Deathbox.)
Try sleep integer in the terminal. It's just how long to wait in seconds. I added that line so you can see the result before the application crashes. You need to pause it or add a time limit which is what you've done with the sleep command. If you want a pause button similar to pause function in batch on MS Windows, you could use the read command instead of a time limit.
Code read -p "This is a message. push a button to resume"
(Jun 3, 2019 06:07 AM)elbone Wrote: That's for a Shell script.
Yes, @OP. It's too late for me to edit my original post but I meant the bash shell (assuming you're using bash) on most Linux systems in the first code snippet that should be saved as a .sh file; as opposed to the following code snippet for a MS Windows batch file which needs the extension .CMD or .BAT. Sorry about the mix up.
Pink Floyd is one of my many addictions. I'm sorry but I'm a free member and thus, I cannot give rep back to you kind folk who have blessed me with your presence.
My howto on Arch servers on ARM devices (samba/dynamicdns/staticip/vncserver/ssh)
https://goo.gl/DgMvRt
DO NOT DEAL WITH THIS MEMBER
(Jun 3, 2019 07:40 AM)Deathbox Wrote: Try sleep integer in the terminal. It's just how long to wait in seconds. I added that line so you can see the result before the application crashes. You need to pause it or add a time limit which is what you've done with the sleep command. If you want a pause button similar to pause function in batch on MS Windows, you could use the read command instead of a time limit.
Code read -p "This is a message. push a button to resume"
Yes, @OP. It's too late for me to edit my original post but I meant the bash shell (assuming you're using bash) on most Linux systems in the first code snippet that should be saved as a .sh file; as opposed to the following code snippet for a MS Windows batch file which needs the extension .CMD or .BAT. Sorry about the mix up. When I execute below commands as .sh file then it show me a black window:
Code #!/usr/bin/env
ping google.co.uk
sleep 3
But when I remove then its worked!!!
(Jun 7, 2019 04:05 AM)hack3rcon Wrote: When I execute below commands as .sh file then it show me a black window:
Code #!/usr/bin/env
ping google.co.uk
sleep 3
But when I remove then its worked!!!
My bad buddy, yeah the shebang line should be #!/usr/bin/env python. It can also be #!/usr/bin/python but the first is recommended. If you don't use either, I believe it uses /usr/bin/python by default. Using the env just means that it will use the first python interpreter in the $path. You can use the following to set the default interpreter. It's common to have 2.7 and 3.x installed.
Code sudo update-alternatives --config python
Or you can do it manually specifying which interpreter
Code #!/usr/bin/python
#!/usr/bin/python3
If you take a look in /usr/bin/ you can see the packages installed on your system. In the image below you can see I have several versions of Python located at /usr/bin and so I would be able to use any of them.
![[Image: Screenshot-from-2019-06-07-13-56-47.png]](https://i.ibb.co/0Q6Gv5Z/Screenshot-from-2019-06-07-13-56-47.png)
Pink Floyd is one of my many addictions. I'm sorry but I'm a free member and thus, I cannot give rep back to you kind folk who have blessed me with your presence.
My howto on Arch servers on ARM devices (samba/dynamicdns/staticip/vncserver/ssh)
https://goo.gl/DgMvRt
DO NOT DEAL WITH THIS MEMBER
wait: https://linuxhint.com/wait_command_linux/ But you can also do something like xterm -hold -e yourscript.sh
DO NOT DEAL WITH THIS MEMBER
(Jun 7, 2019 05:58 AM)Deathbox Wrote: My bad buddy, yeah the shebang line should be #!/usr/bin/env python. It can also be #!/usr/bin/python but the first is recommended. If you don't use either, I believe it uses /usr/bin/python by default. Using the env just means that it will use the first python interpreter in the $path. You can use the following to set the default interpreter. It's common to have 2.7 and 3.x installed.
Code sudo update-alternatives --config python
Or you can do it manually specifying which interpreter
Code #!/usr/bin/python
#!/usr/bin/python3
If you take a look in /usr/bin/ you can see the packages installed on your system. In the image below you can see I have several versions of Python located at /usr/bin and so I would be able to use any of them.
![[Image: Screenshot-from-2019-06-07-13-56-47.png]](https://i.ibb.co/0Q6Gv5Z/Screenshot-from-2019-06-07-13-56-47.png)
It is a bash but why use Python?
(Jun 7, 2019 10:46 PM)hack3rcon Wrote: It is a bash but why use Python?
I tend to have threads open from the Python section, I'm very sorry lol. Yeah for bash, it's just
I'll leave the previous reply, as it explains why you should use env.
Pink Floyd is one of my many addictions. I'm sorry but I'm a free member and thus, I cannot give rep back to you kind folk who have blessed me with your presence.
My howto on Arch servers on ARM devices (samba/dynamicdns/staticip/vncserver/ssh)
https://goo.gl/DgMvRt
DO NOT DEAL WITH THIS MEMBER
(Jun 8, 2019 09:11 AM)Deathbox Wrote: I tend to have threads open from the Python section, I'm very sorry lol. Yeah for bash, it's just
I'll leave the previous reply, as it explains why you should use env.
Thank you so much.
|