Thread: Can't seem to get Psql and Exec to work together
I am trying to run Postgresql's psql using Exec() command. The code is below <? $convert_sql_2 = "\"C:\postgresql\bin\psql.exe -d Geoprocessing -f C:\\postgresql\\bin\\g126.sql"; exec($convert_sql_2,$ds); ?> It didn't insert the data I hope it would. I tested it from the dos command line and it works fine. also i used $convert_sql_2 = "\"C:\postgresql\bin\psql.exe --help"; passthru($convert_sql_2,$ds); It works, giving me the help options. Nyon
On Thu, 2002-11-07 at 05:30, YC Nyon wrote: > I am trying to run Postgresql's psql using Exec() command. > The code is below > > <? > $convert_sql_2 = "\"C:\postgresql\bin\psql.exe -d Geoprocessing -f > C:\\postgresql\\bin\\g126.sql"; > exec($convert_sql_2,$ds); > ?> > > It didn't insert the data I hope it would. I tested it from the dos command > line and it works fine. > also i used > $convert_sql_2 = "\"C:\postgresql\bin\psql.exe --help"; > passthru($convert_sql_2,$ds); > It works, giving me the help options. I know that if I tried such foolery on Linux it would not let me because it would be a different user running the psql - one which was not allowed to access the database. Presumably on "DOS" the same sort of thing is happening. Why not use the pgsql module in PHP and run your commands into PostgreSQL directly anyway? Doing it the way you suggest here just seems a recipe for a disaster! Regards, Andrew. -- --------------------------------------------------------------------- Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267 Survey for nothing with http://survey.net.nz/ ---------------------------------------------------------------------
You probably need to adda -U switch to tell postgresql who you are trying to connect as. It's likely that psql is passing the current user name that your web server is running as and postgresql doesn't know who that is. psql.exe -U username -d Geoprocessing -f filename.sql should work. On Thu, 7 Nov 2002, YC Nyon wrote: > I am trying to run Postgresql's psql using Exec() command. > The code is below > > <? > $convert_sql_2 = "\"C:\postgresql\bin\psql.exe -d Geoprocessing -f > C:\\postgresql\\bin\\g126.sql"; > exec($convert_sql_2,$ds); > ?> > > It didn't insert the data I hope it would. I tested it from the dos command > line and it works fine. > also i used > $convert_sql_2 = "\"C:\postgresql\bin\psql.exe --help"; > passthru($convert_sql_2,$ds); > It works, giving me the help options. > > Nyon > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >
Dear all: I try to write a logging page which can know how the users find my site. if by search engine or some banner switch, they must from another site (yahoo,xxx.com etc.) I try to find it in $HTTP_SERVER_VARS[], seems no, I am not sure. Is ther any Possible way that I can know what is the last URL before the user get into my site? Thank you Steven
Hi, >I try to write a logging page which can know how the users find my site. >if by search engine or some banner switch, they must from another site >(yahoo,xxx.com etc.) >I try to find it in $HTTP_SERVER_VARS[], seems no, I am not sure. >Is ther any Possible way that I can know what is the last URL before the >user get into my site? Have a look in $_SERVER for php4.1.0 and later. There's a variable called 'HTTP_REFERER'.. From the manual .. The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted. It only gets set when you click on a link to go to the site, not if you go there yourself with the url. HTH. Chris. .....>> Open Source - Own it - Squiz.net ...../> W: http://www.squiz.net/ .....>> Open Source - Own it - Squiz.net ...../>
Steven, You can use the $_SERVER['HTTP_REFERER'] to check...however, this is not very reliable. Cause is suggested regarding the validity of the value of this variable. Here is the link: http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server On Fri, 2002-11-08 at 05:52, Steven Lee wrote: > Dear all: > > I try to write a logging page which can know how the users find my site. > if by search engine or some banner switch, they must from another site > (yahoo,xxx.com etc.) > I try to find it in $HTTP_SERVER_VARS[], seems no, I am not sure. > Is ther any Possible way that I can know what is the last URL before the > user get into my site? > > > Thank you > > Steven > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Thank you, Ray Hunter
On Thu, 7 Nov 2002, Steven Lee wrote: > Dear all: > > I try to write a logging page which can know how the users find my site. > if by search engine or some banner switch, they must from another site > (yahoo,xxx.com etc.) > I try to find it in $HTTP_SERVER_VARS[], seems no, I am not sure. > Is ther any Possible way that I can know what is the last URL before the > user get into my site? Others have mentioned $_server[], I'll just add that you can see all the names of the vars you can grab by using either phpinfo(); phpinfo gives up lots of various information. You can use different constants with it. See http://www.php.net/manual/en/function.phpinfo.php for more info. or you can implode the array's keys to get a list like this: print implode(":",array_keys($_server)); Just replace $_server with a different array and you can see what keys it has. You can use the same trick on multi-dimensional arrays like so: print implode(":",array_keys($_server['first_key']));
Thank you all, you are so helpful. Thank again... best regards, Steven ----- Original Message ----- From: "Steven Lee" <blindeagle@telocity.com> To: <pgsql-php@postgresql.org> Sent: Thursday, November 07, 2002 9:52 PM Subject: [PHP] Last URL > Dear all: > > I try to write a logging page which can know how the users find my site. > if by search engine or some banner switch, they must from another site > (yahoo,xxx.com etc.) > I try to find it in $HTTP_SERVER_VARS[], seems no, I am not sure. > Is ther any Possible way that I can know what is the last URL before the > user get into my site? > > > Thank you > > Steven >