Updating variables in a running shell process

Hi I was hoping some one might be able to help me with my problem.
I am trying to write a script that will help organize our print server by identifying when a new file has arrived and deleting the older version.
I have most of the code written that I need although I still have one small problem, in that on occasion the server will log me out In that situation the script will log on and gather new credentials that it holds in a source file of variables called "DFE_CAPTURE" The DFE_CAPTURE file has two variables needed to log on they are called $nID and $JSESSIONID.
My problem is that the running script will not recognize the new variables. Is there a way to have the script check for new variables when ever it runs through another iteration?
I tried using the

unset

command but it breaks the script after the first iteration.
If someone was able to point out what I am doing wrong I would be very thankful for your help
The script below is the one that I use to log on and download a file list that I format into a command with another script to delete duplicate files
Thanks very much
Paul
Below is the code I am using to log on and download a file list.

source /CRACK-U-DFE/DFE_CAPTURE
while true
do
curl -b non-existing http://example.com
curl 'https://rapi.walkme.com/api/4.0/recording/init' -H 'Accept: */*' --compressed -H 'Accept-Language: en-US,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: text/plain;charset=UTF-8' -H 'Host: rapi.walkme.com' -H 'Origin: http://172.20.1.15' -H 'Pragma: no-cache' -H 'Referer: http://172.20.1.15/dfe/main.html' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:59.0) Gecko/20100101 Firefox/59.0' --data ''
curl 'http://172.20.1.15/prodflow/rest/clientlog?feature=c.clientlog&level=error:&nID='$nID'' -H 'Accept: */*' --compressed -H 'Accept-Language: en-US,en;q=0.5' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/xml; charset=UTF-8' -H 'Cookie: JSESSIONID='$JSESSIONID'' -H 'Host: 172.20.1.15' -H 'Pragma: no-cache' -H 'Referer: http://172.20.1.15/dfe/main.html' -H 'Timeout: 120000' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:59.0) Gecko/20100101 Firefox/59.0' --data ''
                        
curl 'http://172.20.1.15/prodflow/rest/jobs?expand=Link&count=100&start=0&event=jobs_table,list&sort=name:ASC&nID='$nID'&feature=p.jobsData.jobs_datatable&rand=1520609843493&nID='$nID'' -H 'Host: 172.20.1.15' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://172.20.1.15/dfe/main.html' -H 'X-Requested-With: XMLHttpRequest' -H 'Cache-Control: no-cache' -H 'Timeout: 120000' -H 'Cookie: JSESSIONID='$JSESSIONID'' -H 'Connection: keep-alive' -H 'Pragma: no-cache' > /CRACK-U-DFE/text_from_web/FileList         
curl 'http://172.20.1.15/prodflow/rest/jobs?expand=Link&count=100&start=100&event=jobs_table,list&sort=name:ASC&nID='$nID'&feature=p.jobsData.jobs_datatable&rand=1520626836283&nID='$nID'' -H 'Host: 172.20.1.15' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://172.20.1.15/dfe/main.html' -H 'X-Requested-With: XMLHttpRequest' -H 'Cache-Control: no-cache' -H 'Timeout: 120000' -H 'Cookie: JSESSIONID='$JSESSIONID'' -H 'Connection: keep-alive' -H 'Pragma: no-cache' >> /CRACK-U-DFE/text_from_web/FileList              
curl 'http://172.20.1.15/prodflow/rest/jobs?expand=Link&count=100&start=200&event=jobs_table,list&sort=name:ASC&nID='$nID'&feature=p.jobsData.jobs_datatable&rand=1520627257572&nID='$nID'' -H 'Host: 172.20.1.15' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://172.20.1.15/dfe/main.html' -H 'X-Requested-With: XMLHttpRequest' -H 'Cache-Control: no-cache' -H 'Timeout: 120000' -H 'Cookie: JSESSIONID='$JSESSIONID'' -H 'Connection: keep-alive' -H 'Pragma: no-cache' >> /CRACK-U-DFE/text_from_web/FileList             
curl 'http://172.20.1.15/prodflow/rest/jobs?expand=Link&count=100&start=300&event=jobs_table,list&sort=name:ASC&nID='$nID'&feature=p.jobsData.jobs_datatable&rand=1520627518182&nID='$nID'' -H 'Host: 172.20.1.15' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://172.20.1.15/dfe/main.html' -H 'X-Requested-With: XMLHttpRequest' -H 'Cache-Control: no-cache' -H 'Timeout: 120000' -H 'Cookie: JSESSIONID='$JSESSIONID'' -H 'Connection: keep-alive' -H 'Pragma: no-cache' >> /CRACK-U-DFE/text_from_web/FileList
curl 'http://172.20.1.15/prodflow/rest/jobs?expand=Link&count=100&start=400&event=jobs_table,list&sort=name:ASC&nID='$nID'&feature=p.jobsData.jobs_datatable&rand=1520627699344&nID='$nID'' -H 'Host: 172.20.1.15' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://172.20.1.15/dfe/main.html' -H 'X-Requested-With: XMLHttpRequest' -H 'Cache-Control: no-cache' -H 'Timeout: 120000' -H 'Cookie: JSESSIONID='$JSESSIONID'' -H 'Connection: keep-alive' -H 'Pragma: no-cache' >> /CRACK-U-DFE/text_from_web/FileList           

if grep -q "UNAUTHORIZED" /CRACK-U-DFE/text_from_web/FileList
then
   /CRACK-U-DFE/DFE_Grab_InFo 
fi

if grep -q "NOT_FOUND" /CRACK-U-DFE/text_from_web/FileList
then
    /CRACK-U-DFE/DFE_Grab_InFo
else
sed -E -e s'/\{\"\link\"\:\[\{\"\rel\"\:\"\self\"/\'$'\n/g' /CRACK-U-DFE/text_from_web/FileList > /CRACK-U-DFE/text_from_web/FileListWorking
fi
unset nID
unset JSESSIONID
sleep 10
done

You lost me here:

Yes - put the source /CRACK-U-DFE/DFE_CAPTURE into the while loop.

1 Like

Hi That work!!
Thanks very much!