LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-17-2017, 02:46 PM   #1
rpiboy
LQ Newbie
 
Registered: Jun 2017
Posts: 4

Rep: Reputation: Disabled
wget/curl/session help


Hi I am a noob and just starting out with curl/wget and I don't know much PHP but I do know bash shell script, that being said, I have a demo website which performs two actions. The first action is you have to start your "work shift" (shift.php) then afterward you can do different tasks such as managing your "staff".(manage_staff.php)

I'm able to start the work shift but when I use the same session cookie as "shift.php" for "manage_staff.php" and perform an action on "manage_staff.php" The server throws and error saying "Start a shift to perform this action"

This is my code which successfully starts a work shift

Code:
wget -q -O- 'http://www.demosite/shift.php'  --save-cookies /home/pi/demositecookie.txt --keep-session-cookies --post-data "action=start_shift"
This is my code which fails to do different tasks because it requires you to start a shift.

Code:
wget -qO -  www.demosite/manage_start.php? --keep-session-cookies --load-cookies /home/pi/demositecookie.txt --post-data="actiom=get_staff_id=1" \

I think the problem is that the authentication isn't cookies-based, and I'm opening a new session with each wget call. How would I prevent that from happening (if that's what happening)?

I think what I want to do is send the HTTP request and basically "navigate" to the page, which I'd imagine is one wget call, but I really don't know how to do it.
 
Old 06-17-2017, 05:20 PM   #2
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
Hi rpiboy,

I'm expecting that the problem isn't as simple as what might be a typing error in the second "code section" of your post:
Code:
--post-data="actiom=get_staff_id=1"
instead of
Code:
--post-data="action=get_staff_id=1"
If you are dealing with a web site, I would have generally expected it to be tested with a browser. Are you not providing an interactive web site with a User Interface, but instead providing a service-based facility? If not service-based, why are you testing with wget?

In general terms I can mention these items:
  1. There are various options for wget that have to do with recursion, and/or following from one place to another, which might conceivably affect a situation where two items from a web site need to work together. But whether they affect something here would depend on the details of the PHP code, and perhaps even the environment in which the PHP is operating.
  2. Often there can be some form of a "Session ID" that creates an association between multiple requests to a web site. I'm used to thinking in terms of a "PHPSESSIONID" specific to PHP-based environments.
  3. In some situations there is a requirement for a "referrer" to be specified on some requests, when going from one web site interaction to the next.

But without more specific details, it would be hard to know how or if, those considerations might apply here.

Last edited by rigor; 06-17-2017 at 05:21 PM.
 
Old 06-17-2017, 07:58 PM   #3
rpiboy
LQ Newbie
 
Registered: Jun 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rigor View Post
Hi rpiboy,

I'm expecting that the problem isn't as simple as what might be a typing error in the second "code section" of your post:
Code:
--post-data="actiom=get_staff_id=1"
instead of
Code:
--post-data="action=get_staff_id=1"
If you are dealing with a web site, I would have generally expected it to be tested with a browser. Are you not providing an interactive web site with a User Interface, but instead providing a service-based facility? If not service-based, why are you testing with wget?

In general terms I can mention these items:
  1. There are various options for wget that have to do with recursion, and/or following from one place to another, which might conceivably affect a situation where two items from a web site need to work together. But whether they affect something here would depend on the details of the PHP code, and perhaps even the environment in which the PHP is operating.
  2. Often there can be some form of a "Session ID" that creates an association between multiple requests to a web site. I'm used to thinking in terms of a "PHPSESSIONID" specific to PHP-based environments.
  3. In some situations there is a requirement for a "referrer" to be specified on some requests, when going from one web site interaction to the next.

But without more specific details, it would be hard to know how or if, those considerations might apply here.
(PHP Version 5.6.23 )
Modules ( core mod_so mod_watchdog http_core mod_log_config mod_logio mod_version mod_unixd mod_access_compat mod_alias mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_filter mod_mime prefork mod_negotiation mod_php5 mod_setenvif mod_socache_shmcb mod_ssl mod_status)

This is the PHP info session http://imgur.com/ah6RTXg
 
Old 06-24-2017, 03:07 PM   #4
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
Sorry for the delay in responding, I've been very busy; Seeing how long it's been, I'm hoping you've been successful at solving the problem in the meantime.

If you've already solved the problem, please mark the thread as resolved.

If not, I should say that AFAIK, from the configuration you posted on Imgur, it looks as though the work flow should be cookie based, as configured, and you shouldn't need a "referer".

I'm guessing using "action" in the post data in the first wget and "actiom" in the second, was a temporary mistake that was since corrected. If not, please explain the difference. There seems to be a backslash at the end of the second wget command in your original post, but I don't see anything after it; is there more to the second wget command that you're using?

I'm not clear on the overall relationship between things with which you're working. I was expecting that "shift.php" and "manage_start.php" might be some of the main active components of page(s) on the web site you're testing. But this comment of yours:
Quote:
I think what I want to do is send the HTTP request and basically "navigate" to the page
made me wonder, is there a single web site, or are you using a URL to one site, to test a second site? If there is more than one site involved, please describe the relationship between the two sites.

Given the PHP configuration, if there is one site, I would expect, with cookie usage, you would generally be able to go from one page to another on the single site. That is, unless the server can't access a directory or file as it's configured, or there's some problem within the PHP files themselves, something beyond the backslash in the second wget command, additional post data that's needed, or something that might not have been mentioned in your original post.

If you can't post the PHP files themselves, it might be possible to try to help you, if you could post the contents of the cookie files and server logs. If either or both are too large to post here, perhaps they could be posted at Imgur.
 
Old 06-29-2017, 11:28 PM   #5
rpiboy
LQ Newbie
 
Registered: Jun 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rigor View Post
Sorry for the delay in responding, I've been very busy; Seeing how long it's been, I'm hoping you've been successful at solving the problem in the meantime.

If you've already solved the problem, please mark the thread as resolved.

If not, I should say that AFAIK, from the configuration you posted on Imgur, it looks as though the work flow should be cookie based, as configured, and you shouldn't need a "referer".

I'm guessing using "action" in the post data in the first wget and "actiom" in the second, was a temporary mistake that was since corrected. If not, please explain the difference. There seems to be a backslash at the end of the second wget command in your original post, but I don't see anything after it; is there more to the second wget command that you're using?

I'm not clear on the overall relationship between things with which you're working. I was expecting that "shift.php" and "manage_start.php" might be some of the main active components of page(s) on the web site you're testing. But this comment of yours: made me wonder, is there a single web site, or are you using a URL to one site, to test a second site? If there is more than one site involved, please describe the relationship between the two sites.

Given the PHP configuration, if there is one site, I would expect, with cookie usage, you would generally be able to go from one page to another on the single site. That is, unless the server can't access a directory or file as it's configured, or there's some problem within the PHP files themselves, something beyond the backslash in the second wget command, additional post data that's needed, or something that might not have been mentioned in your original post.

If you can't post the PHP files themselves, it might be possible to try to help you, if you could post the contents of the cookie files and server logs. If either or both are too large to post here, perhaps they could be posted at Imgur.
Still haven't solve it.
Quote:
I'm guessing using "action" in the post data in the first wget and "actiom" in the second, was a temporary mistake that was since corrected.
That was corrected.
Quote:
There seems to be a backslash at the end of the second wget command in your original post, but I don't see anything after it; is there more to the second wget command that you're using?
There is no more data at the blackslash. The problem I am getting is this I can successfully start a shift on shift.php but when i use the same cookie with shift.php and navigate to manage.php it says you must start a shift.
 
Old 06-29-2017, 11:32 PM   #6
rpiboy
LQ Newbie
 
Registered: Jun 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Send me your email or inbox me it I don't know how to send you my email on here I'll give you full details thanks.
 
Old 06-30-2017, 12:10 AM   #7
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by rpiboy View Post
Send me your email or inbox me it I don't know how to send you my email on here I'll give you full details thanks.
Hi, rpiboy, and welcome to LQ.

That's not how LQ works. All information should be made publicly available on the thread so that folk will be able to use that information to solve similar problems.

You should find a way to post the relevant details here. If there is a lot of info then consider uploading it to a code hosting site and posting the link here.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wget or Curl Issue ulto Linux - Newbie 5 09-17-2015 07:21 AM
How to send sms using wget or curl ? bobbera Linux - General 5 01-15-2012 11:14 AM
Very weird wget/curl output - what should I do? jstilby Programming 1 09-14-2011 01:17 PM
YOU for SUSE 9.1 - curl or wget? djc SUSE / openSUSE 1 02-15-2005 03:26 PM
Wget and cURL can't connect umberleigh Linux - Newbie 0 09-21-2004 05:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration