I am trying to run a shell command in the Linux rc startup script. But the command execution is not successful. I cannot creats a shell script file for this command. Please help on how to execute a shell command in rc file. The command I am giving is as below,
sh -c "echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts"
Thanks for your help
Phani
Related
I have a bash script and I run the script using exec.Command,
But the bash script required a TTY mode, my question how in Go could I run this bash script in TTY mode?
Is it possible?
When I try execute a shell script from within a shell script it works when executing in terminal manually. However, when executing it via a #reboot cron via sudo crontab -e on Raspberry Pi OS it runs everything apart from sh /home/pi/script.sh within the shell script.
My shell script:
#!/bin/sh
clear
sleep 5
python /home/pi/Desktop/Relay-Script-On.py
sleep 3
sh /home/pi/script.sh
sleep 5
python /home/pi/Desktop/Relay-Script-Off.py
sleep 3
I have made the other shell file executable using sudo chmod +x
Note I am still new to shell (apologies if there is an obvious error here).
I am trying to run a script in remote machine using ssh.
sshpass -p "" ssh abc#remote.com "bash -s" < path/file.sh
When I execute this command normally, It is executing.
But when i put this into another shell script and executing it then it showing
no such file or directory
I tried putting #!/bin/bash in the top of code also.
But no use. Please can anyone help me?
Actually second time it runs on your local machine not on remote machine try following
ssh abc#remote.com "cd /home && ls -l"
I am using obsidian scheduler for scheduling various jobs written on a linux box. And trying to call shell scripts with a nohup command like
UPDATE 1:
nohup ./script.sh > output.txt &
UPDATE 2
This is the error when i use nohup.
nohup: failed to run command â./test.sh &>./load.log &â: No such file or directory
I dont see anything writing to the output file.
And secondly how can i verify that it is using nohup command to execute the script.
Thanks
I am running the cmd
script install-log.txt
the terminal successfully returns
Script started, file is install-log.txt
If I begin typing commands and receiving output to the screen
lsblk
fdisk -l
ls
echo ok
when I check the install-log.txt
nano install-log.txt
it is empty.
I thought all cmd was supposed to be saved there until the session is finished?
I am using Arch-Linux installation CD, and wanted to save this log to record my installation setup cmds.
You need to terminate script operation by running 'exit' command. That wont exit your terminal as such. Then you can view your log file.
Here is the duplicate with more detailed info -> Bash script: Using "script" command from a bash script for logging a session