I am trying to create a executor program for regular users on linux with SUID bit set so whatever commands, passed to the program as parameters, get executed with root permission. However when I try to implement this as a bash script, this does not work, where it works when implemented in C. I want to know wh…
Tag: shell
Is it possible to copy files from local windows directory to remote linux directory?
I am using ssh on a remote linux machine from my desktop using putty. I want to copy a txt file which is in the desktop of my local windows machine to the remote linux directory. How can i do that using shell when i am logged in to remote machine using ssh? Thanks for the help! Answer Yes it
Why does (ps -f) create no subshell but a separate process?
I need some help because I don’t get something. From what I read from Internet, a subshell is created when we execute a shell script or if we run command in brackets: ( ) I tried to test this with a script which contains only the following command: When I run it I see the following result: Which is good…
How to read a file line by line
I try to read a file line by line. File to read: Script: When I execute the script, this window will be opened: (Notice how some values are repeated, and the contents don’t correctly alternate between names and versions): I’d like to create an array with all package names and versions. Answer You …
Linux command for public ip address
I want command to get Linux machine(amazon) external/public IP Address. I tried hostname -I and other commands from blogs and stackoverflow like and many more. But they all are giving me internal IP Address. Then I found some sites which provides API for this. Example : curl http://ipecho.net/plain; echo But …
Infinite while not working with os.execvp
I am programming in python which involves me implementing a shell in Python in Linux. I am trying to run standard unix commands by using os.execvp(). I need to keep asking the user for commands so I have used an infinite while loop. However, the infinite while loop doesn’t work. I have tried searching o…
How to check if currently running shell is BusyBox
I tried different variants but none of them can give a distinctive output. I can do something like this but it’s ugly and hackish: Answer Another way requiring Linux and readlink:
bash: Possible to require double Ctrl-c to to exit a script?
End-goal: BASH script that is waiting for background jobs to finish does not abort on first Ctrl-c; instead, it requires a second Ctrl-c to quit. I’m well aware of how the BASH-builtin trap works. You can either: Use it to ignore a signal altogether (e.g., trap ” 2) … or Use it to have arbit…
How can I make a hybrid bash/tcsh script on Linux?
I have one script which runs in Bash and and other which runs in tcsh. I need to run them both from the same script. How can I create a script that can run both bash and tcsh commands? Answer Most shells have an argument which allow you to pass them a string to run as a command, for example,
Check if a condition is false
It is seems to be an easy question, I wonder why googling didn’t give anything helpful — nor in StackOverflow, nor in tutorials. I just need to check using bash that a condition is false. Of what I found I tried and none of them print Hello. I found only two similar questions, but the end answer i…