Updating variables in a running shell process


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Updating variables in a running shell process
# 1  
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
Code:
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.
Code:
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

# 2  
You lost me here:
Quote:
Originally Posted by Paul Walker
. . . on occasion the server will log me out In that situation the script will log on . . .

Quote:
Is there a way to have the script check for new variables when ever it runs through another iteration?
. . .
Yes - put the source /CRACK-U-DFE/DFE_CAPTURE into the while loop.
This User Gave Thanks to RudiC For This Post:
# 3  
Hi That work!!
Thanks very much!
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #739
Difficulty: Medium
BASIC was based on FORTRAN II.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to display only the first 5 running process using top in shell scripting?

topfunc() { top } topfunc Here i used the top command inside a function,and i called the function. when executing this bash file i get all the process which are using by the kernel i just want to display only the first 5 running process. is it possible? (7 Replies)
Discussion started by: Meeran Rizvi
7 Replies

2. Shell Programming and Scripting

Shell script to find out process name that are running for last 10 days.

Hi all, As i am new to shell script.Please help me to write a Shell script to find out process name that are running for last 10 days. Thank's in advance. (8 Replies)
Discussion started by: manas_1988
8 Replies

3. Shell Programming and Scripting

Updating variables using sed or awk

Hi, I have a file(testfile.txt) that contains list of variables as shown below. T $$FirstName=James $$LastName=Fox $$Dateofbirth=1980-02-04 ……and so on there are 50 different variables. I am writing a script(script1.sh) that will update the above three variable one by one with the values... (6 Replies)
Discussion started by: Saanvi1
6 Replies

4. Shell Programming and Scripting

Unset variables in shell when it running two different loops

I have a script to start/stop/restart the tomcat application. When we run the script first time i.e stop/start it set all env variables(DISTRIB_ID,NAME,TOMCAT_CFG,....etc),but when we restart the tomcat it is running in the same shell.....I need to set the variables when i restart the tomcat(in the... (1 Reply)
Discussion started by: praveen265
1 Replies

5. Shell Programming and Scripting

Shell Script to find out if a process is running on any all machines

Hi All, I have been a guest visitor from a long time and this forum is wonderful. I finally am a member of this forum too, so i am here stuck with a shell script that i was trying to write My requirement is that i should be able to create a shell script which will check if a process is running on... (3 Replies)
Discussion started by: Rex0226
3 Replies

6. Shell Programming and Scripting

Running Shell Script in the cron, background process

Hi, i was looking for an answer for some trouble im having runing a script in the cron, thing is, that when i run it manually it works just fine. But when cron runs it, it just doenst work. I saw a reply on a similar subject, suggesting that the . .profile worked for you, but im kind of... (9 Replies)
Discussion started by: blacksteel1988
9 Replies

7. UNIX for Dummies Questions & Answers

Updating environment variables

ok, this definitely falls in the n00b category... I'm trying to upgrade Java on my server and just need to update the PATH, CLASSPATH, and JAVA_HOME environment variables. This is what they currently are:... (4 Replies)
Discussion started by: jtennent
4 Replies

8. UNIX for Advanced & Expert Users

how to check if a process is running in a server from shell script.

I want to write a unix shell script that will check if a process (say debu) is running in the server or not. If no , then send a mail to the corresponding person to start the process??? (2 Replies)
Discussion started by: debu
2 Replies

9. Shell Programming and Scripting

current running process in shell

hi what is the shell programming code to know the number of processes currently running on the machine & information about those processes. Another one is the configuration and usage of the UNIX file system? requesting all for help. thanks (1 Reply)
Discussion started by: moco
1 Replies

10. Shell Programming and Scripting

How to check for specific process running through shell

Hi I want to check whether specific process is running or not through a shell script. ps -ef | grep will tell me this, i tried this way in shell cnt =`ps -ef| grep xyz | awk '{ END {print NR}}` if it return two rows, job is running else not. Is there any better way of doing this. (3 Replies)
Discussion started by: agp
3 Replies

Featured Tech Videos