28 April 2023, 23:12 | #1 |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
Can't set system env variable using C...
Hi,
I am using Bebbo 6.0.5 C compliler. Can I set system global ENV variable somehow? I tried: 1. Using SetEnv() but there is no such a function here... There is only setenv() functino that take only 3 parameters not 4 but it also not working. Code:
setenv("variable", "value", 1); 2. So I tried to use a system call: Code:
system("set variable value"); 3. So I use also Code:
Execute("set variable value") 4. I also foound this piece of code - not working either: Code:
int setenv(const char *var, const char *value, int overwrite) { struct Process *me = (void *) FindTask(NULL); void *old_window = me->pr_WindowPtr; int ret = -1; me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */ if (SysBase->LibNode.lib_Version >= ReqVers) ret = !SetVar((char *)var, (char *)value, -1, GVF_GLOBAL_ONLY | LV_VAR); else { BPTR hand, foot, spine; long len = value ? strlen(value) : 0; if (foot = Lock("ENV:", ACCESS_READ)) { spine = CurrentDir(foot); if (len) { if (hand = Open((char *) var, MODE_NEWFILE)) { ret = Write(hand, (char *) value, len + 1) >= len; Close(hand); } } else ret = DeleteFile((char *) var); UnLock(CurrentDir(spine)); } } me->pr_WindowPtr = old_window; return ret; } but also not working. --- EDIT: --- OK, I used: Code:
system("setenv variable value"); Last edited by mateusz_s; 28 April 2023 at 23:24. |
28 April 2023, 23:18 | #2 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,197
|
can you check with Snoopdos to see what the various programs are doing?
IIRC SetEnv & GetEnv need OS 2.x. |
28 April 2023, 23:25 | #3 |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
|
29 April 2023, 00:13 | #4 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
If you are in kickstart >=2, check this
http://amigadev.elowar.com/read/ADCD.../node01BF.html sample program Code:
#include <proto/dos.h> int main(int argc, char **argv) { SetVar("testing", "42", -1, GVF_GLOBAL_ONLY); return 0; } |
29 April 2023, 02:13 | #5 | |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
Quote:
I cant find this function in my Bebbo 6.5.0 C compiler Instead of SetVar() that takes 4 parameters there is setvar() that takes 3 parametry- but it dont work. I maybe Try ask Bebbo about it. |
|
29 April 2023, 03:15 | #6 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Quote:
Umm, this is how I compiled it with bebbo's gcc 6.5.0 Code:
m68k-amigaos-gcc -O3 -noixemul -o gvar gvar.c |
|
29 April 2023, 17:41 | #7 | |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
Quote:
Hmm.. thats weird. In my case only setvar() tak takes 3 argument is avaiable. The SetVar() isn't. I must check it again.. maybe i missed something. |
|
29 April 2023, 19:11 | #8 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
do you get any error from the compiler when you try to compile the sample I posted above?
|
29 April 2023, 19:33 | #9 |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
|
01 May 2023, 23:27 | #10 | |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
Quote:
before my editor (VisualCode) coulnd't find this function - now its OK - and the compliator/linker finds it too - and its works in the System. Thanks For Help |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Get ENV-variables from Arexx? | Firestone | Coders. Scripting | 6 | 22 August 2022 21:00 |
using Internet to set system Time | utukku | support.Apps | 11 | 20 April 2021 03:49 |
ENV-handler in kickstart | Joel_w | support.Apps | 0 | 02 August 2019 15:02 |
Set System Time | xArtx | Coders. C/C++ | 2 | 04 March 2016 10:24 |
cannot save files to env: | amifreak | support.Hardware | 2 | 20 December 2004 02:01 |
|
|