Sample Header Ad - 728x90

Redirect YAD results into file AND still give exit codes from buttons to STDOUT

1 vote
1 answer
1570 views
I have 2 custom buttons in my yad --form. The user input aka results get redirected into a .txt file for later use. Thats working fine. But it seems like the exit code is not given to STDOUT anymore, when I'm redirecting in this way. But I need the exit code to decide how to move on, of course. Am I on the right path here? Is there another solution that still delivers the exit codes to STDOUT? yad --title="egPorSS - TYPO3 Constants Setup" --center --borders="20" --width="500" --separator="\n" 2> /dev/null \ --form \ --field="egON API-Key":TEXT \ --field="Host for AJAX-Requests":TEXT \ --field="SOAP-Username":TEXT \ --field="SOAP-Password":TEXT \ --field="SOAP-URL:":TEXT \ --field="SEPA-Service":CHK \ --field="Base-Provider":CHK \ --field="Digital Signature":CHK \ --field="Company name":TEXT \ --field="Street, Number":TEXT \ --field="City":TEXT \ --button="Discard entries":1 \ --button="Write to DB":0 > ./temp/constants_modified.txt # Write entries to .txt file. # if Button "Write to DB" is pressed, ask again, before manipulating DB if [ $? -eq 0 ]; then yad --title="egPorSS - TYPO3 Constants Setup" --center --borders="20" 2> /dev/null \ --text="Write changes to constants field in ${DB} now?" \ --button="No, discard":0 \ --button="Yes, write":1 # if "Yes, write" => modify ./temp/constants_${DB}.typoscript" and coll pushConstantsDB() if [ $? -eq 1 ]; then sed -i "s/plugin.tx_egon_pi1.system.apiKey.*/plugin.tx_egon_pi1.system.apiKey = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.system.host.*/plugin.tx_egon_pi1.system.host = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.soap.user.*/plugin.tx_egon_pi1.soap.user = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.soap.password.*/plugin.tx_egon_pi1.soap.password = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.soap.url.*/plugin.tx_egon_pi1.soap.url = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.settings.useSEPA.*/plugin.tx_egon_pi1.settings.useSEPA = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.settings.useBaseProvider.*/plugin.tx_egon_pi1.settings.useBaseProvider = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.settings.signatureAllowed.*/plugin.tx_egon_pi1.settings.signatureAllowed = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.custom.companyName.*/plugin.tx_egon_pi1.custom.companyName = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.custom.companyStreet.*/plugin.tx_egon_pi1.custom.companyStreet = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.custom.companyCity.*/plugin.tx_egon_pi1.custom.companyCity = ${modified}/" ${typoscript} echo -e "${LIBLUE}Writing changes to Database now.. ${NF}\n" pushConstantsDB else echo -e "${LIBLUE}Returning to main menu without any changes.. ${NF}" sleep 6 fi else echo -e "${LIBLUE}Returning to main menu without any changes.. ${NF}" sleep 6 fi
Asked by Wu Wei (113 rep)
Aug 14, 2018, 03:11 PM
Last activity: Oct 16, 2018, 03:24 PM