Batch commands in linux, gnome, bash [closed] - linux

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 11 years ago.
Improve this question
I am trying to make batch commands (sh) on linux for start, stop and restart my web server lighttpd, with partial success.
Ideally, I would like to doubleclick icon and nothing more to do a job.
Now, on doubleclick appear dialog "Do you want to run "START.sh", or display its contents?" and "START.sh" is an executable text file." with Run in terminal, Display, Cancel and Run buttons. Run in terminal do a job after typing password.
My script look as follows:
#! /bin/bash
sudo /bin/bash /etc/init.d/lighttpd start
echo
echo -n " [ENTER] to continue... "
read var_keypress
Is here any way for my script to run without prompted dialog and that I don't need to type password every time?

You can configure sudo to be usable with no password as described here:
http://www.linuxscrew.com/2008/06/22/configure-sudo-nopasswd/
Be sure to let sudo only run specific commands without password, not all.

You could avoid that with a system init script (ln -s /etc/init.d/lighttpd /etc/rc2.d/S99lighttpd on Debian) or with a crontab entry for #reboot

Related

Pop up or sound after completion of any running process in terminal (Linux) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to write a program for having a pop up or sound after completion of any running process in terminals of any Linux distributions.
Many times I run some command in the terminal and leave it to complete the process but then I have to keep checking that whether it has been completed or not. Any suggestions on how to get started with this?
Here's a solution using notify-send, which is available on most linux desktop environments:
yourCommand; notify-send "Completed !:0" "Exit status: $?"
Another tool for such things is zenity:
yourCommand; zenity --info --text "Command !:0 completed with exit code $?"
Both tools are either already installed on your system or easily installable with the package manager. You might want to wrap the above snippets into an alias or into a custom script that you place somewhere in your $PATH.

changes in bash_profile not getting reflected linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Below is the .bash_profile file that I have edited. The changes I make here are not getting reflected when I use echo $JAVA_HOME or echo $PATH.
When I use $PATH, I get /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin which is not found in any of the .bash_profiles or .bash_rcs.
How can I make my .bash_profile work?
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export PATH=/sbin/:$PATH
export PATH=$PATH:$HOME/bin
export JAVA_HOME=/export/home/lg199447/dev/jdk1.7.0_51/bin/java
export PATH=$PATH:/export/home/lg199447/dev/jdk1.7.0_51/bin
Note:
I am trying to login to a server from an OS X terminal using ssh and once I'm logged in my terminal was showing $ followed by my cursor. I was unable to use my arrow keys and tab. So I manually stared bash by executing bash in /bin directory. This changed my terminal as lg199447#VDCALD564 /]$ and I was able to use terminal in a normal way I use in mac.
This sounds like you login shell on the linux machine is not bash, but some other shell variant. ~/.bash_profile is only sourced for bash login shells, so if you just execute bash, it's not.
Either make /bin/bash your login shell (using the command chsh -s /bin/bash), or start bash using bash -l, then it should work.
Another option would be to place your startup code in ~/.bashrc, which is sourced for for all interactive bash sessions (except if explicitly disabled with the --norc option).

How to execute bash script without password? [closed]

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

how to write and run a shell program on terminal without saving it first [closed]

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.

How to change Linux shell in a remote computer that does not support ypchsh [closed]

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?

Resources