If you want everything to be printed to a file, please use redirect >> command after each echo command.
Like for example as follows.
Thanks,
R. Singh
I understand that redirection & appending, but instead of that can i do any modifications to the below line, so that even the echo commands after that would just print to the same log file.
Hi:
I am currently working on a program which requires direct its ouput to a file here is an example
./proram arg_1 arg_2
when program ends all output will be arg_2 file
Is that possible I am not a bad programmer, However I am stuck there.
Can anyone give a hint?
Thanks
SW (1 Reply)
Ahhhrrrggg I'm having a brain fart...
I want to take the output of a command and redirect it to a file...
This works....
$ man cp | cat >> copy_help
but this doesn't
keytool -help |cat >> keytool_help
It just produces... these lines...
more keytool_help
] ...
... (11 Replies)
hello all,
I'm invoking the program generate-report using backticks from my perl program and redirecting the output to the log file sge-stderr.log. But when i check the process using ps command it is spawing two processes where the below code is parent process and the program generate-report as... (2 Replies)
Hi all!!
is possible to assign the output of some command to filename, i.e.
grep_output.txt
Otherwise, I want to open a new file which name is inside another, how can I do it?
Thanks a lot! (7 Replies)
If I want to cat one file and have the output inserted into a specific place on another file, how is this done? I know how to append >> and to overwrite > but say I have a file with:
File1:
abc
def
ghi
jkl
And a File with:
File2:
mno
pqr
stu
vwx
And I want to place the... (5 Replies)
Hi All,
I want to redirect only the file names to a new file from the ls -ltr directroy. how Can i do it.
my ls -ltr output will be as below.
-rwxr-xr-x 1 118 103 28295 Jul 26 2006 event.podl
-rwxr-xr-x 1 118 103 28295 Jul 26 2006 xyz.podl
I want my new file... (6 Replies)
I am trying to get following result from the scipt I have. First time it generates the o/p in correct format. However if I run it again it appends to the existing file. I would like to see o/p on screen as well as save it in file. Everytime it should create new file.
## I/P file
0174
0175... (3 Replies)
Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions.
... (4 Replies)
Hi Guys,
I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts.
I used below but it is not working:
OFILE=/home/home1/report1
echo "report1 details" > $OFILE
=/home/home1/1.sh > $OFILE
echo... (7 Replies)
Hi,
I am using cygwin.
Below is my script that reads all ip ports for iplist.txt and telnets to it.
(
file="iplist.txt"
while read line
do
echo $line
echo $(telnet $line)
done <"$file"
) > output2.txt
~
while the output2.txt gets the first echo but does not show the second... (2 Replies)
Discussion started by: mohtashims
2 Replies
LEARN ABOUT DEBIAN
shell-quote
SHELL-QUOTE(1p) User Contributed Perl Documentation SHELL-QUOTE(1p)NAME
shell-quote - quote arguments for safe use, unmodified in a shell command
SYNOPSIS
shell-quote [switch]... arg...
DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands
or files with embedded white space or shell globbing characters safely. Here are a few examples.
EXAMPLES
ssh preserving args
When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and
passes them to "$SHELL -c". This doesn't work as intended:
ssh host touch 'hi there' # fails
It creates 2 files, hi and there. Instead, do this:
cmd=`shell-quote touch 'hi there'`
ssh host "$cmd"
This gives you just 1 file, hi there.
process find output
It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to
split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote:
eval set -- `find -type f -print0 | xargs -0 shell-quote --`
debug shell scripts
shell-quote is better than echo for debugging shell scripts.
debug() {
[ -z "$debug" ] || shell-quote "debug:" "$@"
}
With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can.
save a command for later
shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command
you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are
things the user can't pass through), you can do something like this:
user_switches=
while [ $# != 0 ]
do
case x$1 in
x--pass-through)
[ $# -gt 1 ] || die "need an argument for $1"
user_switches="$user_switches "`shell-quote -- "$2"`
shift;;
# process other switches
esac
shift
done
# later
eval "shell-quote some-command $user_switches my args"
OPTIONS --debug
Turn debugging on.
--help
Show the usage message and die.
--version
Show the version number and exit.
AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions.
AUTHOR
Roderick Schertler <roderick@argon.org>
perl v5.8.4 2005-05-03 SHELL-QUOTE(1p)