|
The statement args = &inputBuffer; in the setup() function, does not change the args variable in main() . Also you have not split the input buffer into its separate components. I would spend some time parsing your input to ensure it's in the correct format before worrying about using the fork() and execvp() functions.
|
|
|
|
|
I did that it works fine but like execvp("ls",args);
not like your code execvp("ls","-1");
it's work perfect and execute the all ls command
but it's possible to put any command I prefer? for example ps -el or any another shell command for Linux O.S?
|
|
|
|
|
dr.nokia wrote: not like your code execvp("ls","-1");
I didn't post any code
dr.nokia wrote: but it's possible to put any command I prefer?
It's some while since I did this, or used Linux, but in theory I think you can put any command into the exec() functions. The key as always is getting your parameters organised correctly according to the version of the exec() call that you are making.
As I said before, I think the important thing is to get comfortable with parsing strings and using function calls and their parameters correctly. Once you have your head round those concepts then the second half is easy.
|
|
|
|
|
you mean to check my command then invoke it to execvp() ?
|
|
|
|
|
dr.nokia wrote: you mean to check my command then invoke it to execvp() ?
Well I'm not exactly sure what your level of expertise is, so I was really trying to suggest that you get comfortable with the simple things before moving to the more complex ones. The same as any learning process really.
|
|
|
|
|
Really I wana be very good in programming if you have explanation about this and signals also and sources please get it to me
|
|
|
|
|
Actually I need to very clear in C then coz im studying computer science then and im taking OOP and then I will teach my self C# and more advanced programming courses.
By the way the industry for programming what the most wanted programming languages in this days?
|
|
|
|
|
dr.nokia wrote: Really I wana be very good in programming.
First you need ability, which some have in greater measure than others.
Second you need to study and work hard, in whatever environment and language you choose, whether it is ASP.NET, .NET, or plain Win32 using VB.NET, C#, C++, Java etc.
Third there is no such word in English as "wana" or indeed "wanna".
dr.nokia wrote: By the way the industry for programming what the most wanted programming languages in this days?
No idea, look in the trade journals in your country to see what is most in demand.
|
|
|
|
|
dr.nokia wrote: Really I wana be very good in programming
So do All of us.
The key is to start at the beginning, preferably with something simple, e.g.: Work with an example provided by others, Read Books,etc. until you have a basic grasp of the concepts involved. I think what you are trying at the moment is still out of your reach, given the level of knowledge you demonstrate.
Bram van Kampen
|
|
|
|
|
Hi All,
I have an application in which i am taking an LOGINREC structure variable like this LOGINREC m_loginrec which is defined in syblogin.h of SYBASE SDK 11.1.1
and my code is like this
if ((m_loginrec = dblogin()) == 0)
{
TRACE0("dbl: couldn't get loginrec.\n");
return FALSE;
}
// Set the login timeout value.
dbsetlogintime(m_login_time);
// Set up the loginrec.
if (m_application.GetLength() > 0)
DBSETLAPP(m_loginrec, (char *) (const char *) m_application);
if (m_user.GetLength() > 0)
DBSETLUSER(m_loginrec, (char *) (const char *) m_user);
if (m_password.GetLength() > 0)
DBSETLPWD(m_loginrec, (char *) (const char *) m_password);
if (m_host.GetLength() > 0)
DBSETLHOST(m_loginrec, (char *) (const char *) m_host);
// Open the connection.
if ((m_dbproc = dbopen(m_loginrec, (char *) (const char *)m_server)) == 0)
{
TRACE1("dbl: couldn't open connection to server %s.\n",
(char *) (const char *) m_server);
return(FALSE);
}
The problem of mine is
As i will get LOGINREC pointer through dblogin() function,that pointer i am passing through dbopen() function.My code is perfectly working in vs-2003 in MS-2000 machine...
But when i migrate the code it is returning the proper LOGINREC when i enter correct login and password otherwise The entire application is getting crashed when i enter wrong username/password...
Can i change or define my own LOGINREC (or) It is with problem of VISTA machine...?
Can anybody suggest...?
Thanks in Advance
|
|
|
|
|
If the problem is occurring only in Vista, it could be a permission issue.
Try the same exercise with UAC turned off.
Also, try it with an Administrator and Non-Administrator account.
|
|
|
|
|
Hi thank you for reply...
Actually we are using SYBASE SDK11.1.1 in MS-2000....But In Vista OS,Microsoft has come with SDK 12.5.1
Can you please tell am i getting this problem because of the SDK?
Should i install the same SDK into my Vista Machine??
Please Suggest..
And please tell me how to turn off UAC
|
|
|
|
|
It is always good to have the latest SDK installed.
You can turn off UAC by going to Control Panel -> User Accounts .
There you will find a link called Turn User Account Control on or off .
|
|
|
|
|
Hi thank you for reply...
Actually we are using SYBASE SDK11.1.1 in MS-2000....But In Vista OS,Microsoft has come with SDK 12.5.1
Can you please tell am i getting this problem because of the SDK?
Should i install the same SDK into my Vista Machine??
Please Suggest..
|
|
|
|
|
Vetukuri Raju wrote: It is with problem of VISTA
Probably! You say it worked fine under 2000.
Vista has changed many things in subtle ways, IMHO in most cases for no good reason.
One way around this (although not elegant),is to set up a try/catch block.
With some carefull crafting, maybe you can even elicit the same behaviour for the User under Vista as under 2000. This would obviate a need for two versions of your software.
Bram van Kampen
|
|
|
|
|
Hi thank you for reply...
Actually we are using SYBASE SDK11.1.1 in MS-2000....But In Vista OS,Microsoft has come with SDK 12.5.1
Can you please tell am i getting this problem because of the SDK?
Should i install the same SDK into my Vista Machine??
AND
Actually my code is like this..I am using a callback function in my application...
if (dlg.DoModal() != IDOK) {
PostQuitMessage(0);
return 0;
}
else {
lstrcpyn(_loginfo.dbpwd, dlg.m_csPassword, 31);
lstrcpyn(_loginfo.dbid, dlg.m_csUser, 31);
lstrcpyn(_loginfo.dbsrv, dlg.m_csServer, 31);
lstrcpyn(_loginfo.dbdb, dlg.m_csDatabase, 31);
}
_dbproc = dbConnect (&_loginfo, _T("Phoenix"));
if (_dbproc != NULL)
break;
msg = (::GetKeyState (VK_CAPITAL) & 0x0001) ? IDS_ERR_LOGINFAILEDCAPS : IDS_ERR_LOGINFAILED;
if (AfxMessageBox (msg, MB_OKCANCEL | MB_ICONHAND) == IDCANCEL) {
PostQuitMessage(0);
return 0;
}
}
And CALLBACK function is like this....
At below code(bolded) my application getting crashed...
DBPROCESS NEAR * CALLBACK dbConnect (LPLOGINFO li, LPSTR app)
{
DBPROCESS NEAR *dbproc;
LOGINREC *login;
if ((login = dblogin ()) == NULL)
return (DBPROCESS NEAR *) NULL;
DBSETLHOST (login, _dbhost);
DBSETLUSER (login, li->dbid);
DBSETLPWD (login, li->dbpwd);
DBSETLAPP (login, app);
dbproc = dbopen (login, li->dbsrv);
dbfreelogin (login);
if (dbproc != (DBPROCESS NEAR *) NULL)
dbuse (dbproc, li->dbdb);
return dbproc;
}
My control is not coming to _dbproc from the CALLBACK function
So without i get return value how can i apply try and catch..
can you please help further..
|
|
|
|
|
Hi,
Vetukuri Raju wrote: Actually we are using SYBASE SDK11.1.1 in MS-2000....But In Vista OS,Microsoft has come with SDK 12.5.1
Can you please tell am i getting this problem because of the SDK?
Should i install the same SDK into my Vista Machine??
I am Unfamiliar with SyBase, I just gave a general approach to such a problem.
What is your Target Platform. If it is Vista Only, maybe you should try the Upgrade. If it is a mixture of systems, Common sense states that you should consider if the new SDK is compatible with all the platforms your customers have.
Vetukuri Raju wrote: My control is not coming to _dbproc from the CALLBACK function.
So without i get return value how can i apply try and catch..
That does not matter, you do not need a return value if things go wrong. An exception was thrown somewhere, you must catch it yourself, if you don't the System will catch it, and close down your app.
Just try something like:
for(;;){
try{
if (dbproc != (DBPROCESS NEAR *) NULL){
dbuse (dbproc, li->dbdb);
return dbproc;
}
}
catch(...){
AfxMessageBox("Invalid Name or Password");
continue;
}
}
In the above if anything in the try{ } block throws an exception, control will be passed to the code in your
catch{ } block, Here you handle the exception by showing a Messagebox, and try again.
The above will probably some work, but I hope you get the General Idea. (A good idea would be to allow the user to enter a New Password, or, to exit ).
Regards,
Bram van Kampen
|
|
|
|
|
hi sorry for the late reply....
i tried like this
if ((login = dblogin ()) == NULL)
return (DBPROCESS NEAR *) NULL;
DBSETLHOST (login, _dbhost);
DBSETLUSER (login, li->dbid);
DBSETLPWD (login, li->dbpwd);
DBSETLAPP (login, app);
try
{
dbproc = dbopen (login, li->dbsrv);
}
catch(..)
{
some code.....
}
dbopen is a Sybase function,in which the control is going(when calling dbopen() function)
But the control is not comming back to handle the exception..
|
|
|
|
|
Hi,
We are using raw sockets with IPPROTO_ICMP. We are facing problem in Win2008. When the network cable of the server machine is removed then Winsock api Select( ) is returning wrong value.Due to that we are observing behavior difference in Win2003 and Win2008.
We have the following code in our application.
int bread;
SOCKET sockRaw;
sockRaw = WSASocket(
AF_INET,
SOCK_RAW,
IPPROTO_ICMP,
NULL, 0,0);
//All socket connection and initialization code
fd_set set = {1,{sockRaw}};
timeval timeValue = {TIMEOUT_PERIOD_SEC, 0};
bread = select(NULL,&set,NULL,&set,&timeValue
If we remove the network cable of the server application ie., network failure then bread is 0 in Win2003, 1 in Win2008 . Due to this we are observing a behavior difference in the application in a particular scenario. What needs to be done so that bread is 0 even in Win2008 in case of network failure.
Any help would be appreciated.
Thanks..
|
|
|
|
|
I have made a custom Button with text on the button.
I want to change the color of button, color of the text on the button and the border color on the button . I have to use CColorDialog to select the desired color.
Anyone know the way, how to do this?
|
|
|
|
|
Use the OnCtlColor [^] message handler.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello, I am going to develop a service program. with VC.
can Anyone help me to start this work?
brief and useful articles that I can use they
thank you
Zo.Naderi-Iran
|
|
|
|
|
zon_cpp wrote: can Anyone help me to start this work?
brief and useful articles that I can use they
You could always try this[^].
|
|
|
|
|
See, for instance, here [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|