Sponsored Content
Top Forums Shell Programming and Scripting [Bash] passing variables to executable doesn't work Post 303039696 by sushi2k7 on Saturday 12th of October 2019 11:51:45 AM
Old 10-12-2019
[Bash] passing variables to executable doesn't work

Bash version 4.4.20 / Ubuntu 16.0.4


Hello,
I tried to write a script that gathers some data and passes them to an executable.
The executed application answers with an error. The echo output in the script returns correct values.
If I copy/paste the last echo command, it get's executed correctly.

You can't reproduce the error, maybe you can improve the code that it should work then.


Code:
 
#!/bin/bash

#creates an array with name gettx
declare -a gettx

#enter your public address from: StealthCoind getaddressesbyaccount ""
pubaddress=mzYfB7ZEurhm8UosBc1a5t4QtRCHjtVw4Z

#enter your pubkey from: StealthCoind getqposinfo
pubkey=0364d6d9039b74c69e2a7dabd81ff27c5cab0b7d54cda0f7419b94e02ff91f9

#Does a transaction and stores the transaction id into the txid variable
txid=$(StealthCoind sendtoaddress $pubaddress 0.01)

#Fill the gettx array with the needed vout number
gettx=($(awk -F: '{split($2,a,","); print a[1]}' <<<"$(StealthCoind gettransaction $txid | sed -n /0.01000000/,/}/p)"))

#Show content of txid for debugging
echo "TXID: $txid"

#show vout number for debugging
echo "vout n: ${gettx[1]}"

#show the build command chain for debugging
echo "StealthCoind claimqposbalance $txid ${gettx[1]} 10"

#execute the command to claim
StealthCoind claimqposbalance $txid ${gettx[1]} 10


Last edited by sushi2k7; 10-12-2019 at 02:21 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

bash pattern matching echo *[! '/' ] doesn't work

without using ls, just using echo so purely pattern matching I can say echo */ <-- lists directories but how would I match files? surely something like *!/ or * but neither work ? it seems like there isn't much that I can put in but surely i should be able to put any ascii... (1 Reply)
Discussion started by: james hanley
1 Replies

2. Shell Programming and Scripting

Perl cmds doesn't work in Bash shell . Plz help

Hi everyone, I have a Linux OS in my PC (older version 9). Its default shell is bash. Whenever I try to run some Perl program it throws error ! eg, if I run this simple PERL program , #!/usr/bin/perl printf "\lHello \n"; $var=3 ; printf $var; @list=(1,2,3); printf "@list";... (6 Replies)
Discussion started by: adc22
6 Replies

3. Shell Programming and Scripting

cd command doesn't work through variables

Hi.... cd command is not working when dual string drive/volume name is passed to cd through variables....... For Ex.... y=/Volumes/Backup\ vipin/ cd $y the above command gives error....... anyone with a genuine solution ? (16 Replies)
Discussion started by: vipinchauhan222
16 Replies

4. Ubuntu

set completion-ignore-case on doesn't work in bash

completion-ignore-case option doesn't work in my version: /home/user $ echo $BASH_VERSION 3.2.48(1)-release /home/user $ ls -l * -rw-r--r-- 1 user user 0 2009-10-18 00:09 somefile -rw-r--r-- 1 user user 0 2009-10-18 00:09 Somefile /home/user $ set completion-ignore-case on But when I... (2 Replies)
Discussion started by: Sapfeer
2 Replies

5. Shell Programming and Scripting

Perl variables inside Net::Telnet::Cisco Module doesn't work

I am writing perl script to configure Cisco device but Variables inside Net::Telnet::Cisco Module doesn't work and passed to device without resolving. Please advise. here is a sample of script: use Net::Telnet::Cisco; $device = "10.14.199.1"; ($o1, $o2, $o3, $o4) = split(/\./,$device);... (5 Replies)
Discussion started by: ahmed_zaher
5 Replies

6. Shell Programming and Scripting

pipe to grep doesn't work in bash script

Hi, I'm trying to write a script that checks gvfs to see if a mount exists so I can run it from network-manager's status hooks. I thought I'd pipe the output of gvfs-mount -l to grep for the particular mounts I care about. When I do this in a bash script: cmnd="gvfs-mount -l | grep -i... (4 Replies)
Discussion started by: kcstrom
4 Replies

7. Shell Programming and Scripting

Why double quotation marks doesn't work in ksh function parameters passing?

I'm working on AIX 6, ksh shell. The parameters are some strings quotated by double quotation marks which from a file. They are quotated because there may be spaces in them. Example: "015607" "10" " " "A"I want to pass these parameters to a shell function by writing the following command: ... (4 Replies)
Discussion started by: Shimmey
4 Replies

8. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

9. Shell Programming and Scripting

Rsync in bash script doesn't work even after placing pub key in target server

Hello Friends, My bash script is like this #!/bin/bash # request Bourne shell as shell for job #$ -S /bin/bash # assume current working directory as paths #$ -cwd #$ -N rsync-copy # # print date and time date rsync -rltD --progress "ssh -i /home/myname/.ssh/id_rsa"... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

10. UNIX for Beginners Questions & Answers

Bash diff date doesn't work

Hi everyone, I've an issue trying to soustracte two dates, e.g: d1=$(date -d "Nov 18, 2017" +%s) d2=$(date +%s) # Today we are 2017-11-16 echo "$(( (d1 - d2) / 86400 ))" Output: 1 I don't understand why it doesn't work. for me, it should give "18 - 16 = 2". Much appreciated... (1 Reply)
Discussion started by: Arnaudh78
1 Replies
asadmin-set(1AS)						   User Commands						  asadmin-set(1AS)

NAME
asadmin-set, set - sets the values of attributes SYNOPSIS
set--user admin_user[--password admin_password][--host localhost] [--port 4848][--secure|-s] [--passwordfile filename] [--terse=false] [--echo=false] [--interactive=true] attributename=value [attribute_name=value]* Sets the values of one or more configurable attribute. This command is supported in remote mode only. On Solaris, quotes are needed when executing commands with * as the option value or operand. OPTIONS
--user authorized domain application server administrative username. --password password to administer the domain application server. --host machine name where the domain application server is running. --port port number of the domain application server listening for administration requests. --secure if true, uses SSL/TLS to communicate with the domain application server. --passwordfile file containing the domain application server password. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. Default is false. --echo setting to true will echo the command line statement on the standard output. Default is false. --interactive if set to true (default), only the required password options are prompted. OPERANDS
attributename=value identifies the attribute name and its value. See the Application Server Reference for a listing of the available attribute names. Example 1: Using set asadmin> set --user admin --password adminadmin --host localhost --port 4848 server.transaction-service.automatic-recovery=true EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-get(1AS), asadmin-list(1AS) J2EE 1.4 SDK March 2004 asadmin-set(1AS)
All times are GMT -4. The time now is 12:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy