With 2>&1 you are redirecting STDERR to STDOUT. From the first look of the script, it seems to be broken. Can you please post the whole script with CODE tag around it? I do not see anything where you are feeding errors to STDERR.
Combining commands using pipe!! I have not seen anyone using pipe for this sort of thing. Plus, with this, commands are executed right-to-left. Have you ever considered using "&&" instead?
I do not see idtoolerrorlog a script file or a binary executable. How do you even expect this to be working? Are you trying to copy the idtoolerrorlog file to test? If yes, where is the cp command in front?
Ohh yes, by some magical way, the code that you posted earlier (pasted below) vanished!! I am wondering why!!
There is lots of redundancy and pointless things in here.
#!/bin/bash
#Linux Script
echo "`date +%D:%H:%M:%S`" ; read -p " User ID"= UserID
# You don't need a file.
# echo "`date +%D:%H:%M:%S`" ; read -p "Enter Server(s)"= servertext && echo $servertext > serverlist
echo "`date +%D:%H:%M:%S`"
read -p "Enter Server(s)"= servertext
# Just use the variable itself. That's what it's there for.
for i in $servertext
do
echo "$i"
echo "`date +%D:%H:%M:%S`"
ssh -t -t $i id $UserID
file="`date +%b_%d_%y:%H:%M:%S`"
# You don't need to touch the file.
# touch $file
# You don't need to move the file.
# mv $file ~/errors/idtoolerrorlogs
# This is all that's needed.
~/idtool 2> ~/errors/idtoolerrorlogs/$file
# If you want it to append, not overwrite, do this:
# ~/idtool 2>> ~/errors/idtoolerrorlogs/$file
done
I have another question. Lets say the scripts name is "idtoolflinux" and I want to copy any errors form the output of this script (when I say output I mean as I press the command ./idtoolflinux and see the errors on the screen) to file mention below ; how would I go about doing it?
I do like the "exec 2> ~/errors/idtoolerrorlogs/$file" command (without the quotation marks). The problem is the error messege shows up in the file and not on the screen. Is there anyway have the error error message show up on the screen and in the file?
echo "`date +%D:%H:%M:%S`" ; read -p " User ID"= UserID
echo "`date +%D:%H:%M:%S`"
read -p "Enter Server(s)"= servertext
for i in $servertext
do
echo "$i"
echo "`date +%D:%H:%M:%S`"
ssh -t -t $i id $UserID
tixuw #Also added this just to recreate an error
done
Well , the error was trapped in the "$file" but it not show up on the screen and I was still able to continue with the script. So, if this is as far as we can go then thank you very much for your help. This is my first time created a series of major scripts and this really showed me how much more I have to learn. But if there is another way to pull of looking at the error on the screen and putting in a file a the same time, please show me how. Thanks again.