Sponsored Content
Top Forums Shell Programming and Scripting Issue while executing C executable with argument in shell script Post 302865681 by wisecracker on Saturday 19th of October 2013 06:30:48 AM
Old 10-19-2013
I decided to do a PSV to CSV longhand for fun:-
Code:
#!/bin/bash --posix
# Done longhand to show that the default shell can convert.
# Your example 'PSV' file...
text="aadsa=1|dasdsa=adsada-4096|wedewq=sdsadasasdsa|wqewqe=weww-sadasd\
|C2S=004120F1707E4928|DOI=1225906924|DOE=1226511724|ISS=1|NUM=28036|CM\
T=chassis52license|LSP=22000|LSH=22000|LSG=11000|LSL=11000|LSC=10000|L\
EC=1000|LGT=11000|LSA=22000|FIS=Y|FR4=Y|FPP=Y|FTC=Y|FMG=Y|FCR=Y|FSR=Y|\
FPM=Y|FID=Y|FI6=Y|FLI=Y|FPF=Y|FFA=Y|FCA=Y|FUT=Y|FSS=Y|FDB=Y|FDA=Y|FTM=\
Y|FDU=Y|FTP=Y|FTA=Y|FFP=Y|FSA=Y|LIM=19100|LCC=19100|LPC=100|LIS=100|FD\
R=Y|BME=Y|qwewqe=Y|BSC=Y|FRC=Y|FMN=Y|FBM=Y|FDC=Y|FGR=Y|FAA=Y|FRF=Y|FDQ=Y|\
FEL=Y|FIN=Y|qeqweqw=Y|BKO=Y|BEP=Y|FIP=Y|FRO=Y|LSI=11000|LSR=11000|LSS=1100\
0|LSN=11000|qwewqe=Y|LSW=21000|FCC=Y|FCP=Y|LCF=1000|LPP=1000|FVM=Y|FVG=Y|\
FPD=Y|FPR=Y|FVA=Y|FES=Y|FSN=Y|FCD=Y|LSF=1000|FVI=Y|FON=Y|FLS=Y|FSG=Y|F\
qweqe=Y|qwewq=Y|wwqe=Y|adsa=Y|FPC=Y|asdasd=Y|ads=asdad/adaddadas+AU\
aasdasd/qweqwe"
echo -n "$text" > /tmp/psvfile
# Note the line separaters '\' are GONE!
# Now re-use the 'text' variable.
text=$(cat < /tmp/psvfile)
echo "$text"
# Get length of file.
file_len="${#text}"
echo "$file_len"
# Quick visual check to see if files are identical.
echo "$text"
csvtext=""
comma=","
# Ensure file_len offset does not over flow...
file_len=$[ ( file_len -1 ) ]
for n in $( seq 0 1 $file_len )
do
	if [ "${text:n:1}" == "|" ]
	then newtext=$newtext$comma
	else newtext=$newtext${text:n:1}
	fi
done
echo "$newtext"
echo -n "$newtext" > /tmp/csvfile
cat < /tmp/csvfile
echo -e "\n\nYou now have a CSV file.\n"
# Done!

And the results:-
Code:
Last login: Sat Oct 19 11:17:54 on ttys000
AMIGA:barrywalker~> ./psv_csv.sh
aadsa=1|dasdsa=adsada-4096|wedewq=sdsadasasdsa|wqewqe=weww-sadasd|C2S=004120F1707E4928|DOI=1225906924|DOE=1226511724|ISS=1|NUM=28036|CMT=chassis52license|LSP=22000|LSH=22000|LSG=11000|LSL=11000|LSC=10000|LEC=1000|LGT=11000|LSA=22000|FIS=Y|FR4=Y|FPP=Y|FTC=Y|FMG=Y|FCR=Y|FSR=Y|FPM=Y|FID=Y|FI6=Y|FLI=Y|FPF=Y|FFA=Y|FCA=Y|FUT=Y|FSS=Y|FDB=Y|FDA=Y|FTM=Y|FDU=Y|FTP=Y|FTA=Y|FFP=Y|FSA=Y|LIM=19100|LCC=19100|LPC=100|LIS=100|FDR=Y|BME=Y|qwewqe=Y|BSC=Y|FRC=Y|FMN=Y|FBM=Y|FDC=Y|FGR=Y|FAA=Y|FRF=Y|FDQ=Y|FEL=Y|FIN=Y|qeqweqw=Y|BKO=Y|BEP=Y|FIP=Y|FRO=Y|LSI=11000|LSR=11000|LSS=11000|LSN=11000|qwewqe=Y|LSW=21000|FCC=Y|FCP=Y|LCF=1000|LPP=1000|FVM=Y|FVG=Y|FPD=Y|FPR=Y|FVA=Y|FES=Y|FSN=Y|FCD=Y|LSF=1000|FVI=Y|FON=Y|FLS=Y|FSG=Y|Fqweqe=Y|qwewq=Y|wwqe=Y|adsa=Y|FPC=Y|asdasd=Y|ads=asdad/adaddadas+AUaasdasd/qweqwe
786
aadsa=1|dasdsa=adsada-4096|wedewq=sdsadasas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=Y,FON=Y,FLS=Y,FSG=Y,Fqweqe=Y,qwewq=Y,wwqe=Y,adsa=Y,FPC=Y,asdasd=Y,ads=asdad/adaddadas+AUaasdasd/qweqwe

You now have a CSV file.

AMIGA:barrywalker~> _

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script $0 argument

Hi, If not running a shell script file in current shell (. ./fileName) then $0 represents the executable file name. But in case of invoking shell script file in current shell then i m getting "$0 as -bash" . In such case how can i get the program name (running shell script file name)? Thanks, (2 Replies)
Discussion started by: painulyarun
2 Replies

2. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

3. Shell Programming and Scripting

convert shell script into a binary executable

Hello every one, i want to convert my shell script into a binary executable a .exe file , is it possible to do that if so are there any tools . Would the script take off when the arguments are parsed. Thanks Venu (13 Replies)
Discussion started by: venu
13 Replies

4. Shell Programming and Scripting

Passing argument to a script while executing it within current shell

Hi Gurus, I have written a script set_env.ksh to which I pass an argument and set the oracle login credentials based on the argument I pass. The script has code as below. ORACLE_SID=$1 DB_SCHEMA_LOGON=$DB_SCHEMA_USER/$DB_SCHEMA_PASSWORD@$ORACLE_SID; export DB_SCHEMA_LOGON; echo... (3 Replies)
Discussion started by: Sabari Nath S
3 Replies

5. Shell Programming and Scripting

Shell script to find the sum of argument passed to the script

I want to make a script which takes the number of argument, add those argument and gives output to the user, but I am not getting through... Script that i am using is below : #!/bin/bash sum=0 for i in $@ do sum=$sum+$1 echo $sum shift done I am executing the script as... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

6. Shell Programming and Scripting

Issue while executing script

Hi, I'm trying to use the below command in a shell script, but couldn't. The command is working fine when I'm executing from the dollar prompt i.e. shell. Command: grep -i fail /home/applmgr/error.log |egrep -i "`date --date="-4 day" +"%m/%d/%Y"`|`date --date="-4 day" +"%m/%d/%y"`"... (8 Replies)
Discussion started by: venkatesh17
8 Replies

7. Shell Programming and Scripting

Issue on executing db2 queries through shell script

hi i am trying to execute db2 queries through shell script. it's working fine but for few queries is not working ( those queries are taking time so the script is not waiting to get the complete the execution of that query ) could you please any one help me on this is there any wait... (1 Reply)
Discussion started by: bhaskar v
1 Replies

8. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

9. AIX

executable problems with shell script in IBM servers

We have a java stand alone application running currently on sun Solaris system. The java application runs on Jdk 1.4. We are reshooting this java application to new Ibm servers. There are 10 unix scripts for this application. All scripts works well except one shell script, This shell... (2 Replies)
Discussion started by: poojagupta
2 Replies

10. Shell Programming and Scripting

Issue handling single quoted argument in shell script.

Below is my script that works fine and prints the desired output: #!/bin/ksh echo "$1" | while IFS= read -r dirpath do echo "DIRR_PATH:$dirpath" install_dir=$install_dir" "$dirpath done echo "Desired Output:$install_dir" Output: ./loopissue.sh... (10 Replies)
Discussion started by: mohtashims
10 Replies
All times are GMT -4. The time now is 04:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy