Shell Script not working

Forum rules
Before you post please read this

Shell Script not working

Postby registereduser on Sat Oct 20, 2012 12:10 am

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.
registereduser
Level 2
Level 2
 
Posts: 66
Joined: Tue Aug 23, 2011 3:40 pm

Linux Mint is funded by ads and donations.
 

Re: Shell Script not working

Postby bigj231 on Sun Oct 21, 2012 5:02 pm

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*
Running on a 4-slot toaster @ 60Hz
User avatar
bigj231
Level 5
Level 5
 
Posts: 793
Joined: Fri Feb 26, 2010 10:16 am
Location: Middle of Nowhere

Re: Shell Script not working

Postby Pilosopong Tasyo on Wed Oct 24, 2012 10:23 pm

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.
Image
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].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1120
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 0 guests