My shell script generates a bunch of lines of text and passes this text as an argument to a perl script.
I'm able to do this, but for some reason newlines don't get recognized in the perl script and so the script just prints actual '\n' instead of carriage returning, otherwise everything gets passed just fine.
Not even sure what's causing this, but I'll settle for a solution.
Putting it in quotes causes it to pass it as one single argument. It's not perl that has to understand the newlines, it's the shell.
Keeping everything as one giant string like that is subject to limits, you know. On many systems you're not guaranteed anything more than 4 kilobytes of data in commandline arguments! If your data will ever be more than a page or so, you should be feeding the data into stdin instead of into arguments, as well as not storing it all in one giant variable inbetween, to prevent it being truncated when the data gets large. If you post your shell code we can show you how to adapt it, and on the perl side, you'd do something like:
and on the shell side, something like
On some shells, you can kludge your existing solution like
which will cause arguments to temporarily be split on newlines but not on other whitespace, splitting $results into arguments the way you want.
Hello,
I am trying to execute an SQL query from shell script.
A part of script is something like this:
fromDate=`echo $(date +"%F%T") | sed "s/-//g" | sed "s/://g"`
$ORACLE_HOME/sqlplus -s /nolog <<EOD1
connect $COSDBUID/$COSDBPWD@$COSDBSID
spool... (4 Replies)
Hi all,
How to pass the command line argument to a sql file
Script:
#!/bin/ksh
if ] ; then
test.sql
fi
My Sql Informix DB:
echo "select * from table where col1 = 2234
and col2 = '$3'"|dbaccess ddname
But im getting `:' unexpected error (5 Replies)
I have to pass a sentence in a file, the specs are as:
cat run | sed 's/SRT/'$8'/g' | sed 's/plength/68/g' | sed 's/stcol/'$5'/g' | sed 's/encol/'$6'/g' | sed 's/brdtype/'$1'/g' | sed 's/brdtxt/'$3'/g' | sed 's/demotxt/Total '$2'/g' | sed 's/bantxt/ban_'$7'/g' | sed 's/validcodes/'$4'/g' >... (15 Replies)
I need to process a file line-by-line using some value from a shell variable
Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt
I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.)
I have searched and found... (4 Replies)
I'm a beginner and wasn't able to google my problem...
I would like to pass a string with spaces to a shell script.
my test_shell:
#!/bin/sh -vx
#######################################################
# generate_documentation (c) Ch.Affolter Nov. 2009 Version 1.0 #... (3 Replies)
I have a perl script that opens a text file containing numbers on each line:
for example:
755993
755994
755995
755996
755997
755998
The perl script takes these numbers and store them as an array @raw_data, where I can access individual numbers by using $raw_data for the value 755993.... (2 Replies)
Hi Folks,
The subject is my question:
Can we pass an array of strings from a Perl Program to a Shell Script?
Please provide some sample code.
Thanks
---------- Post updated at 11:52 PM ---------- Previous update was at 11:43 PM ----------
I got it.
Its here:... (0 Replies)
Hi,
Please guide to pass an array as a arg to a script...
for example,
I have a script small.sh to find the small no of given arg as below...
#! /bin/sh
# this script is for finding the small number
set -A arr_no_updates
small=$1
i=1
for arr in $@
do
if (3 Replies)
Hi,
I,m writing a program in shell script and currently this script is calling a java program.
I have a problem to pass string variable from my shell script to the java program. I don't know on how to pass it and how the java program can call what I have pass from the shell script.
This is... (3 Replies)