Shell Script not working

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
registereduser

Shell Script not working

Post by registereduser »

Can someone tell me why this won't work?

Code: Select all

#!/bin/bash
ps auxww |grep " dd " |grep -v grep |awk '{print $2}' |while read pid; do kill -USR1 $pid; done
I placed it into a file and made the file executable, but when I run it, there's no progress for dd displayed. If I enter this command into a virtual terminal it displays the progress in the dd window.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
bigj231

Re: Shell Script not working

Post by bigj231 »

I know when I made some shell scripts, I had to give the complete location of the commands, i.e /usr/bin/sudo instead of just sudo. It had the exact same problem.
If you don't know where a command is located, use:

Code: Select all

which *command*
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Shell Script not working

Post by Pilosopong Tasyo »

registereduser wrote:Can someone tell me why this won't work?
...
I placed it into a file and made the file executable, but when I run it, there's no progress for dd displayed. If I enter this command into a virtual terminal it displays the progress in the dd window.
The script's output will not display because it doesn't know where to display its output since it's not running inside an open terminal window. You are running it from within the GUI, which normally doesn't open a terminal window when running scripts. Compare that with running the script with a terminal window already open, you will see whatever output it prints out.

If you want to see output when you run the script within the GUI, the simplest way to do it is select the [Run in Terminal] button when you double-click the icon. Assuming of course that your file manager prompts you, that is.

There are other ways to do this; see this thread for more info on the issue.
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Locked

Return to “Scripts & Bash”