- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: AWK script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 01:19 AM
01-24-2011 01:19 AM
I created an awk script long time ago, now i need to modify this script inserting a new operationinside it.
the source file is something like this:
adjksfhluawe='string1_to_encrypt'afjskdasndkajcfc
asjrhquwerfb='string2_to_encrypt'sfjsejkbghbvzjhs
....
The new command porpose is to encrypt a string inside the original file.
I have already created an external shell script that allow me to encrypt the string.
The shell script work like this:
ShellEncrypt.sh string_to_encrypt
The output of the script will bee an ecrypted same size string.
eg.
ShellEncrypt.sh text
the output of the file will be a string like:
A3rA
I tried to use the system function inside the awk script and this partially works.
Will follow my awk program:
prog.awk script:
#########################
BEGIN { FS = "'" }
$0 ~ /'/ {
printf ($1 "'");
system("ShellEncrypt.sh "$2"");
printf ("'" $3);
}
#########################
and awk command line:
# awk -f prog.awk source.txt
Unfortunately the result will be not the expected one because after the ecryption of the string with the system command
I have the following output:
adjksfhluawe='ecrypted_string_1_
'afjskdasndkajcfc
asjrhquwerfb='ecrypted_string_2_
'sfjsejkbghbvzjhs
Instead my expected output was:
adjksfhluawe='ecrypted_string_1_'afjskdasndkajcfc
asjrhquwerfb='ecrypted_string_2_'sfjsejkbghbvzjhs
Can you help me to find a solution?
Thanks in advance for your help.
Regards
Bernardo
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 03:19 AM
01-24-2011 03:19 AM
Re: AWK script
You might be able to suppress it with:
system("X=$(ShellEncrypt.sh " $2 "); echo $X\\c")
(You may have to add more backslashes.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 03:42 AM
01-24-2011 03:42 AM
Re: AWK script
for example:
result expected:
adjksfhluawe='ecrypted_string_1_'afjskdasndkajcfc
test 1
system("X=$(ShellEncrypt.sh " $2 "); echo $X\\c"
result:
adjksfhluawe='ecrypted_string_c_
'afjskdasndkajcfc
test 2
system("X=$(ShellEncrypt.sh " $2 "); echo $X\\\c"
result:
adjksfhluawe='ecrypted_string_'afjskdasndkajcfc
test 3
system("X=$(ShellEncrypt.sh " $2 "); echo $X\\\\c"
result:
adjksfhluawe='ecrypted_string_'afjskdasndkajcfc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 04:14 AM
01-24-2011 04:14 AM
Re: AWK script
your suggestion works correctly.
I found a mistake in the ShellEncrypt.sh script.
I corrected it and now it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 04:18 AM
01-24-2011 04:18 AM
Solutionadjksfhluawe='ecrypted_string_'afjskdasndkajcfc
adjksfhluawe='ecrypted_string_1_'afjskdasndkajcfc
You need to explain why these aren't the same? (I assumed these were produced by your script.)
Do you want the awk script to number each output with "_N_"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 04:56 AM
01-24-2011 04:56 AM
Re: AWK script
Sorry for the previous reply.
Your suggestion works correctly.
I found a mistake in the ShellEncrypt.sh script.
I corrected it and now it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2011 04:58 AM
01-24-2011 04:58 AM
Re: AWK script
system("X=$(ShellEncrypt.sh " $2 "); echo $X\\\c")
Regards,
Bernardo