In CentOS, I would like to run a script which is archived as a .tar file, but when I try to do it, it does not recognize 'read' command.
The main idea is run this script without save on disk
- Listing the contents or the .tar file
tar -tf script.rar
- Returns it:
[user@host]$ tar -tf script.rar teste-1.sh
Making untar,or extracting the file and trying to execute it
tar -xvf script.rar | xargs bash
your full info is:
[user@host]$ tar -xvf script.rar | xargs bash your full info is: [user@host]$ tar -xvf script.rar | bash - bash: line 1: teste-1.sh: command not found [user@host]$ tar -xvf script.rar | sh - sh: line 1: teste-1.sh: command not found
Like shown above, the output is the last line of the code and not shows the read prompt. The full simple code just for test purpose is:
#!/bin/bash read -p "type your name:" name read -p "type lastname:" lastname echo "your full info is: $name $lastname"
When I try to execute it manually , it works without problems (without being archived)
[user@host]$ ./teste-1.sh type your name:jhon type lastname:doe your full info is: jhon doe
- I have tried to use
| sh -,
| bash -, but without success. Does anyone have an interesting idea?, thank you so much!