How to use xquery to extract form data from html? - xquery

<form action='https://myurl.com' name='form2' id="form2" method='post'>
<input type='hidden' name='abc' value='xxx'>
<input type="hidden" name="efg" value="yyy">
</form>
Suppose that I have the above form in an HTML page, I'd like to extract the data to be posted abc=xxx&efg=yyy and print it to stdout. Does anybody know how to do it with xidel? Thanks.

If your HTML file is saved as test.html, the following xidel command will return the results you're expecting:
xidel test.html --xpath="string-join(//input ! (#name || '=' || #value), '&')"
The results:
**** Retrieving: test.html ****
**** Processing: test.html ****
abc=xxx&efg=yyy
If the HTML is on an HTTP server, just replace test.html with the URL:
xidel http://localhost:8080/exist/rest/db/test.html --xpath="string-join(//input ! (#name || '=' || #value), '&')"
Results:
**** Retrieving (GET): http://localhost:8080/exist/rest/db/test.html ****
**** Processing: http://localhost:8080/exist/rest/db/test.html ****
abc=xxx&efg=yyy
(Note that Xidel was forgiving with the unescaped ampersand, which I originally expected would throw an error, but I tried because there doesn't seem to be an explicit option for output:method='text'.

Related

How to add a background image inline style to link tag Rails

I just can't seem to get this right.
In my rails app I am using ActionCable, it has issues with sending over URLs in partials. To fix this I am going to let the CSS do the work of setting the image, only to allow the image to be set dynamically I am going to need to have access to the view hence the fact this has to be inline css.
.message
%a.message_profile-pic{ :href => "", {:style=>"background-image:url('avatar.png')" } }
I have an image called avatar.png in my app/assets/images directory just as a test. It's an empty a-tag for now but it will become a link_to once I sort out the profile sections of the app.
I am getting the following error:
SyntaxError - syntax error, unexpected ')', expecting =>
...nd-image:url('avatar.png')" } )}></a>\n #{
How do I set this? I am using Rails 5 rc1 and Ruby 2.3 with bootstrap.
Note:
I have also tried the new HAML syntax with the same result:
%a.message_profile-pic{ :href => "", style: {background-image: "url('avatar.png')"}}
Edit
Here is what better errors is showing me:
Full stack trace looks like this:
SyntaxError - syntax error, unexpected ')', expecting =>
...nd-image:url('avatar.png')" } )}></a>\n #{
... ^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:6: unknown regexp option - a
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:6: syntax error, unexpected $undefined
));}\n </a>\n <span class='message_timestamp'>\n #{
^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:6: syntax error, unexpected keyword_class, expecting keyword_do or '{' or '('
));}\n </a>\n <span class='message_timestamp'>\n #{
^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:6: syntax error, unexpected $undefined
));}\n </a>\n <span class='message_timestamp'>\n #{
^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:8: syntax error, unexpected '}', expecting tSTRING_DEND
));}\n </span>\n <span class='m...
^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:8: unknown regexp options - pa
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:8: syntax error, unexpected $undefined
...n class='message_star'></span>\n <span class='message_conte...
... ^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:8: syntax error, unexpected keyword_class, expecting keyword_do or '{' or '('
...ge_star'></span>\n <span class='message_content'>\n #{
... ^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:8: syntax error, unexpected $undefined
...<span class='message_content'>\n #{
... ^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:11: syntax error, unexpected '}', expecting tSTRING_DEND
));}\n </span>\n</div>\n", -2, f...
^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:11: unknown regexp options - dv
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:11: syntax error, unexpected $undefined
));}\n </span>\n</div>\n", -2, false);::Haml::Util.h...
^
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:11: unterminated string meets end of file
/Users/ruberto/Personal/Projects/splat/app/views/messages/_message.html.haml:11: syntax error, unexpected end-of-input, expecting tSTRING_DEND:
You can do something like this:
:style => "background-image: url(#{image_path "avatar.png"})"
To find more about image_path.

Unexpected token ILLEGAL with dangerouslySetInnerHTML

I am using Symfony2 framework with reactjs for view part. I have a twig variable having html tags.
So I did this - <span {{"dangerouslySetInnerHTML={{__html: ' "~content|raw~" '}}"}}></span>
But this is giving me following error
Error: Parse Error: Line 95: Unexpected token ILLEGAL
at http://localhost/url/abcd
... ouslySetInnerHTML={{__html: '<p></p><p&g ...
When I write something like <span {{"dangerouslySetInnerHTML={{__html: '<div>abcd</div>'}}"}}></span> , Then everything works fine. But when I use a twig variable, this error is thrown.
I would recommend using twig only to output your delimiters and the variable itself:
<span dangerouslySetInnerHTML={{ '{{' }}__html: '{{ content|raw }}' {{ '}}' }}></span>

Capture and check bteq return code in Unix

I'm developing a script which in turn invokes several other scripts (.ksh). And basically when one of them fail they shouldn't proceed to the next one. So I tried checking for the return code in one script that involves bteq (Basic Teradata Query) session. Please find below the scenario:
bteq <<EOF!
.run file ${TGTRUNFILEN} ;
.maxerror 1;
.set width 245;
...
...
sel * from table ;
.if ACTIVITYCOUNT <> 0 then .GOTO QUIT
.os mail command "error msg"
exit 1;
.LABEL QUIT
.quit;
EOF!
echo $rcode
rcode=$?
if [[ $rcode != 0 ]]
then
echo "$0: Insufficient Perm Space : username " >&2
exit 4
fi
Here,the script fails and I can see the log saying failed with return code 1, but why isn't the text "$0:Insufficient Perm Space : Username" displayed. I think it exits the entire script, but I need this fixed somehow.
Can someone kindly help me on this?
Hi Thanks a ton for responding.I found a way to overcome this.I just added 'set' command like this.
set +e
bteq <<EOF!
...
...
EOF!
rcode=$?
set -e
Works fine for me.
Cheers

Prompting the user for file names in Unix

I want to write a script which prompts the user for the names of two files, lists the first file on screen and waits for user to press any key before second file is listed on the screen. But I am unsure of how to do this. Could anyone help? I think its something like:
VALID_FILENAME_ONE="Test1"
VALID_FILENAME_TWO="Test2"
echo "Please enter first file name:"
read file_name1
echo "Please enter second file name:"
read file_name2
if [ "$file_name1" == "$VALID_FILENAME_ONE"]; then
ls -l | Test1
else
echo "No further action"
fi
But this does not run correctly. Any help would be much appreciated.
In the following line:
if [ "$file_name1" == "$VALID_FILENAME_ONE"]; then
... add a space between "$VALID_FILENAME_ONE" and the closing square bracket, like this:
if [ "$file_name1" == "$VALID_FILENAME_ONE" ]; then
Otherwise, bash can't parse your syntax.

iframe Onload Visibility

I am trying to hide an iframe until it is loaded by I keep getting an error with the following code:
jquery("some stuff">.html("<iframe frameborder='0' vspace='0' hspace='0' marginwidth='0'
allowtransparency='true' scrolling='no' marginheight='0'
style='visibility:hidden;' onload="this.style.visibility='visible';" width='600'
class='frm'></iframe>").appendTo('body');
But it returns an error "syntax error this.style.visibility".
Can anyone help ?
edit:fixed spelling but now get the error
'missing ) after argument list'
You have a typo. Should be
this.style.visibility='visible';
required exit quotes \ and \
onload=\"this.style.visibility='visible';\"

Resources