Umount: target is busy to variableumount failed: device busyBusy Device on UmountRecursive umount after rbind...
What are the map units that WGS84 uses?
Draw the ☣ (Biohazard Symbol)
How should Thaumaturgy's "three times as loud as normal" be interpreted?
Why are UK MPs allowed to not vote (but it counts as a no)?
How to create large inductors (1H) for audio use?
Why would one hemisphere of a planet be very mountainous while the other is flat?
Book where main character comes out of stasis bubble
Why does the UK Prime Minister need the permission of Parliament to call a general election?
Professor refuses to write a recommendation letter to students who haven't written a research paper with him
Could this estimate of the size and mass of the Chicxulub Impactor be accurate?
Can you fix a tube with a lighter?
What is the justification for Dirac's large numbers hypothesis?
Remaining in the US beyond VWP admission period
Types of tablet... a tablet secretion
Entering the US with dual citizenship but US passport is long expired?
Was the lunar landing site always in the same plane as the CM's orbit?
Temporarily simulate being offline programmatically
If I sell my PS4 game disc and buy a digital version, can I still access my saved game?
Can taking my 1-week-old on a 6-7 hours journey in the car lead to medical complications?
Male viewpoint in an erotic novel
Is the interior of a Bag of Holding actually an extradimensional space?
Friend is very nit picky about side comments I don't intend to be taken too seriously
How to measure the statistical "distance" between two frequency distributions?
Is there a neutral term for people who tend to avoid face-to-face or video/audio communication?
Umount: target is busy to variable
umount failed: device busyBusy Device on UmountRecursive umount after rbind mountlist files and store it in variablesVariable not expanding inside another variable bashHow do I know when lazy `umount -l` completes?Ensure writing has completed after `umount -l / --lazy`Variable in variable expansionLazy unmount root jail drives
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I want to check if a USB is busy and store the result in a variable:
$ foo=$(umount /dev/sdb1)
$ umount: /path/mounted: target is busy.
But when I want to print $foo, I get an empty variable
$ echo $foo
$
My final goal is to umount the USB. If the target is busy, issue a warning to the user, using whiptail. So:
$ [[ -z $foo ]] || whiptail --msbox "Cancel the operation that is maintaining your USB busy" 0 0
Is it possible to store the error target is busy on a variable, or should I use another kind of technique?
shell-script variable variable-substitution error-handling unmounting
add a comment |
I want to check if a USB is busy and store the result in a variable:
$ foo=$(umount /dev/sdb1)
$ umount: /path/mounted: target is busy.
But when I want to print $foo, I get an empty variable
$ echo $foo
$
My final goal is to umount the USB. If the target is busy, issue a warning to the user, using whiptail. So:
$ [[ -z $foo ]] || whiptail --msbox "Cancel the operation that is maintaining your USB busy" 0 0
Is it possible to store the error target is busy on a variable, or should I use another kind of technique?
shell-script variable variable-substitution error-handling unmounting
umount /dev/sdb1 || whiptailshould work.
– jordanm
35 mins ago
@jordanm Thanks, it seems that works
– guillermo chamorro
30 mins ago
add a comment |
I want to check if a USB is busy and store the result in a variable:
$ foo=$(umount /dev/sdb1)
$ umount: /path/mounted: target is busy.
But when I want to print $foo, I get an empty variable
$ echo $foo
$
My final goal is to umount the USB. If the target is busy, issue a warning to the user, using whiptail. So:
$ [[ -z $foo ]] || whiptail --msbox "Cancel the operation that is maintaining your USB busy" 0 0
Is it possible to store the error target is busy on a variable, or should I use another kind of technique?
shell-script variable variable-substitution error-handling unmounting
I want to check if a USB is busy and store the result in a variable:
$ foo=$(umount /dev/sdb1)
$ umount: /path/mounted: target is busy.
But when I want to print $foo, I get an empty variable
$ echo $foo
$
My final goal is to umount the USB. If the target is busy, issue a warning to the user, using whiptail. So:
$ [[ -z $foo ]] || whiptail --msbox "Cancel the operation that is maintaining your USB busy" 0 0
Is it possible to store the error target is busy on a variable, or should I use another kind of technique?
shell-script variable variable-substitution error-handling unmounting
shell-script variable variable-substitution error-handling unmounting
edited 12 mins ago
G-Man
15.3k9 gold badges44 silver badges84 bronze badges
15.3k9 gold badges44 silver badges84 bronze badges
asked 42 mins ago
guillermo chamorroguillermo chamorro
7161 silver badge13 bronze badges
7161 silver badge13 bronze badges
umount /dev/sdb1 || whiptailshould work.
– jordanm
35 mins ago
@jordanm Thanks, it seems that works
– guillermo chamorro
30 mins ago
add a comment |
umount /dev/sdb1 || whiptailshould work.
– jordanm
35 mins ago
@jordanm Thanks, it seems that works
– guillermo chamorro
30 mins ago
umount /dev/sdb1 || whiptail should work.– jordanm
35 mins ago
umount /dev/sdb1 || whiptail should work.– jordanm
35 mins ago
@jordanm Thanks, it seems that works
– guillermo chamorro
30 mins ago
@jordanm Thanks, it seems that works
– guillermo chamorro
30 mins ago
add a comment |
1 Answer
1
active
oldest
votes
Programs commonly write error messages to the “standard error” I/O stream;
“stderr” for short.
If you search for that term, you’ll gets millions of results;
the short explanation is that stderr exists so error messages can and will
go to the screen when the “standard output” (“stdout”) is redirected,
as in a hypothetical command like
umount /dev/sdb1 > um.result.txt
And you can see this happening; the error message appears on your screen
even though you are trying to capture it in a variable.
The equally short answer is to use 2>&1
to merge the stderr stream into the stdout stream, so
foo=$(umount /dev/sdb1 2>&1)
will capture the error message in the variable.
Another approach, as suggested by jordanm in a comment,
is to look at the exit status.
Variations on this theme include:
umount /dev/sdb1 || complain to user
if ! umount /dev/sdb1
then
complain to user
fi
umount /dev/sdb1 2> /dev/null || complain to user
foo=$(umount /dev/sdb1 2>&1) || complain to user using "$foo"
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f539282%2fumount-target-is-busy-to-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Programs commonly write error messages to the “standard error” I/O stream;
“stderr” for short.
If you search for that term, you’ll gets millions of results;
the short explanation is that stderr exists so error messages can and will
go to the screen when the “standard output” (“stdout”) is redirected,
as in a hypothetical command like
umount /dev/sdb1 > um.result.txt
And you can see this happening; the error message appears on your screen
even though you are trying to capture it in a variable.
The equally short answer is to use 2>&1
to merge the stderr stream into the stdout stream, so
foo=$(umount /dev/sdb1 2>&1)
will capture the error message in the variable.
Another approach, as suggested by jordanm in a comment,
is to look at the exit status.
Variations on this theme include:
umount /dev/sdb1 || complain to user
if ! umount /dev/sdb1
then
complain to user
fi
umount /dev/sdb1 2> /dev/null || complain to user
foo=$(umount /dev/sdb1 2>&1) || complain to user using "$foo"
add a comment |
Programs commonly write error messages to the “standard error” I/O stream;
“stderr” for short.
If you search for that term, you’ll gets millions of results;
the short explanation is that stderr exists so error messages can and will
go to the screen when the “standard output” (“stdout”) is redirected,
as in a hypothetical command like
umount /dev/sdb1 > um.result.txt
And you can see this happening; the error message appears on your screen
even though you are trying to capture it in a variable.
The equally short answer is to use 2>&1
to merge the stderr stream into the stdout stream, so
foo=$(umount /dev/sdb1 2>&1)
will capture the error message in the variable.
Another approach, as suggested by jordanm in a comment,
is to look at the exit status.
Variations on this theme include:
umount /dev/sdb1 || complain to user
if ! umount /dev/sdb1
then
complain to user
fi
umount /dev/sdb1 2> /dev/null || complain to user
foo=$(umount /dev/sdb1 2>&1) || complain to user using "$foo"
add a comment |
Programs commonly write error messages to the “standard error” I/O stream;
“stderr” for short.
If you search for that term, you’ll gets millions of results;
the short explanation is that stderr exists so error messages can and will
go to the screen when the “standard output” (“stdout”) is redirected,
as in a hypothetical command like
umount /dev/sdb1 > um.result.txt
And you can see this happening; the error message appears on your screen
even though you are trying to capture it in a variable.
The equally short answer is to use 2>&1
to merge the stderr stream into the stdout stream, so
foo=$(umount /dev/sdb1 2>&1)
will capture the error message in the variable.
Another approach, as suggested by jordanm in a comment,
is to look at the exit status.
Variations on this theme include:
umount /dev/sdb1 || complain to user
if ! umount /dev/sdb1
then
complain to user
fi
umount /dev/sdb1 2> /dev/null || complain to user
foo=$(umount /dev/sdb1 2>&1) || complain to user using "$foo"
Programs commonly write error messages to the “standard error” I/O stream;
“stderr” for short.
If you search for that term, you’ll gets millions of results;
the short explanation is that stderr exists so error messages can and will
go to the screen when the “standard output” (“stdout”) is redirected,
as in a hypothetical command like
umount /dev/sdb1 > um.result.txt
And you can see this happening; the error message appears on your screen
even though you are trying to capture it in a variable.
The equally short answer is to use 2>&1
to merge the stderr stream into the stdout stream, so
foo=$(umount /dev/sdb1 2>&1)
will capture the error message in the variable.
Another approach, as suggested by jordanm in a comment,
is to look at the exit status.
Variations on this theme include:
umount /dev/sdb1 || complain to user
if ! umount /dev/sdb1
then
complain to user
fi
umount /dev/sdb1 2> /dev/null || complain to user
foo=$(umount /dev/sdb1 2>&1) || complain to user using "$foo"
edited 16 mins ago
answered 27 mins ago
G-ManG-Man
15.3k9 gold badges44 silver badges84 bronze badges
15.3k9 gold badges44 silver badges84 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f539282%2fumount-target-is-busy-to-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
umount /dev/sdb1 || whiptailshould work.– jordanm
35 mins ago
@jordanm Thanks, it seems that works
– guillermo chamorro
30 mins ago