Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
How do I execute a script on ssh? I need to execute:
/scripts/makecpphp
So I have tried run /scripts/makecpphp but it didn't work. Any help would be greatly appreciate. I know for sure that that file exists there.
If the script is on the remote machine:
ssh user#foo.example.com /scripts/makecpphp
If it's on the local machine:
/scripts/makecpphp
If makecpphp is executable, you just need to type:
./scripts/makecpphp
Are you sure it's executable? Note that this does not just apply over ssh, but any time you are running programs via a linux command line.
If it's executable, just do
/scripts/makecpphp
Otherwise you can do (replace $INTERPRETER by the used interpreter, eg bash, python,...)
$INTERPRETER /scripts/makecpphp
First off, do you have the permission to execute it and is it executable?
Secondly, I don't believe you would use run. You'd cd to the directory and then type
./makecpphp
you need to have execute permission on the script.
chmod +x /scripts/makecpphp
then run
/scripts/makecpphp
Related
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Here is our test script...
#!/bin/bash
echo "Hello World"
It is on an NFS share that is mounted on a Linux client. If we call the script like this:
./testscript.sh
then we get this:
sh: ./testscript.sh: Permission denied
If we call it like this:
bash ./testscript.sh
then it executes properly. Also, if we run it on the local filesystem, then it executes correctly without the "bash" prepended.
Any way to do this so that the shebang works? By the way, permissions are wide open on this. 777.
Edit 1:
I found the issue.
I had "user" set in the mount options for the NFS mount. Apparently that removes the ability to execute. I changed that and now it seems to be working.
Use the chmod command to set the executable flag:
chmod +x testscript.sh
Then execute it:
./testscript.sh
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I need to execute the script after system boot.
For example:
(sleep 5 && (sudo dhcpcd wlp4s0))
What I need: Executing the script.
What I have: [sudo] password for eugene:
I has been edited /etc/sudoers so:
eugene ALL=NOPASSWD: /home/eugene/dhcpcdstart.sh
But it's ineffectually. How I can to execute the current script without password?
Arch Linux 2013.05.01
I just tested your sudoers configuration and it works (not with dhcpcd, since I don't have it). Just make sure that you put that line at the end of sudoers file containing dhcpcd in the file list (I guess your script has executing rights for eugene user, but dhcpcd doesn't).
eugene ALL=NOPASSWD: dhcpcd_path/dhcpcd
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am working on a Linux server, I have access to a directory but I am not allowed to write anything to that directory. I can run commands from system prompt. Now I have to find values of specific field of some files in that dir and do some comparisons. I have a script on a test server can do that. But I can't install my script to the server, I am asking if there is anyway I type a specific command, then I can write and run a shell program without saving the program? Thank you!
If you have the script on another host, you can run it this way:
wget http://your.host.net/script -O- | sh -s
If the host is not accessible via HTTP, you can use any other protocol you want.
Also you can write a script direct in a shell:
sh -s <<EOF
echo Hello
echo I am script
echo Nice to meet you
EOF
You can use backtics to execute the result of another command.
`wget /path/to/your/script/stored/remotely -O-`
(you might use sftp to fetch the script instead)
Another option is to write a program that uses a tty to control an ssh session, then the script is stored on the ssh client but the commands run on the server. Perhaps the expect tool would help with that.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm working with the sed editor and I realize that my command prompt is:
[darkchild#localhost ~]$
How can I change this so that it ends in #....and what does this mean?
for example:
[darkchild#localhost ~]#
A friend told me to write this command #!/bin/bash but it does not change the prompt to #.
Can someone educate me?
Canonically # means root shell. You probably do not actually want to do this, because it would confuse other users of your system. If you do actually want to do this, you can edit the PROMPT variable.
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/
You can run the following command:
set prompt=\[`id -nu`#`hostname -s`\]\#\
This is the root user. You can go to this user using the su command.
More info: http://en.wikipedia.org/wiki/Su_(Unix)
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How do I change shell in a remote PC? I am logged into a cluster with a Bash and the output I see is
elan#l01:~ $ chsh
chsh: can only change local entries; use ypchsh instead.
elan#l01:~ $ ypchsh
-bash: ypchsh: command not found
Since I have no root privilege there, I can not install ypchsh in the cluster. Is there any other way to change shell without invoking ypchsh?
Note 1:
Browsing, it looks like another user who installed the same software (currently not available for questioning) has .cshrc in his directory, with the right settings. His .bashrc is minimal and has no redirections.
The /etc/passwd has no entry for either of us.
getent passwd
shows entry for both of us, but shows only /bin/bash for both.
Note 2:
The sofware has been developed with autotools, and using bash instead of tcsh is known to have created wrong builds. (I am not changing shell because I fancy it.)
Thank you,
Elan
In your .bashrc, put exec tcsh last.
Once you're in bash in the cluster, why don't you just type tcsh? And if that works, why not just add it as the last line of .bashrc?