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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-17-2017, 02:46 PM
|
#1
|
LQ Newbie
Registered: Jun 2017
Posts: 4
Rep:
|
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.
|
|
|
06-17-2017, 05:20 PM
|
#2
|
Member
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705
Rep:
|
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:
- 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.
- 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.
- 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.
|
|
|
06-17-2017, 07:58 PM
|
#3
|
LQ Newbie
Registered: Jun 2017
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by rigor
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:
- 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.
- 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.
- 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
|
|
|
06-24-2017, 03:07 PM
|
#4
|
Member
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705
Rep:
|
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.
|
|
|
06-29-2017, 11:28 PM
|
#5
|
LQ Newbie
Registered: Jun 2017
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by rigor
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.
|
|
|
06-29-2017, 11:32 PM
|
#6
|
LQ Newbie
Registered: Jun 2017
Posts: 4
Original Poster
Rep:
|
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.
|
|
|
06-30-2017, 12:10 AM
|
#7
|
LQ Guru
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
|
Quote:
Originally Posted by rpiboy
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.
|
|
|
All times are GMT -5. The time now is 06:44 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|