- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Moving of files using c programming..
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 05:41 PM
02-23-2005 05:41 PM
Moving of files using c programming..
- Tags:
- link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 05:58 PM
02-23-2005 05:58 PM
Re: Moving of files using c programming..
If you are planning to do some C programming on
HP-UX (or other Unix) environment, you should
really consider buying the following book:
Advanced Programming in the UNIX(R) Environment
by W. Richard Stevens
http://www.amazon.com/exec/obidos/ISBN%3D0201563177/104-5204610-5331128
The chap 3 and 4 deals with file and directory
manipulations and deals with the problem you are
trying to solve.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 06:21 PM
02-23-2005 06:21 PM
Re: Moving of files using c programming..
but if I just want to move files from one path to the other can't I just used
link("/path/*", "/dest");
apparently it doesnt seems to work.
?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 06:33 PM
02-23-2005 06:33 PM
Re: Moving of files using c programming..
but link() is a system call and may not associate
any special meaning to '*'. So you need to open the
directory file, find all the filenames in the directory
and run a for loop to copy each file to the dest dir
by using link() call. If you want the shell to copy the
files inside a C program, you need to use system()
call instead of link(). The way to do that would be
the following:
system ("cp /path/* /dest");
This will enable the C program to fork a shell and do
the copy. But this kind of defeates the whold
purpose of writing a C program instead of a shell
script.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 07:46 PM
02-23-2005 07:46 PM
Re: Moving of files using c programming..
Using system is the easy way out, otherwise need to view the documentation above or find a similar source of information, like the sources of the mv command (might check out linux sources, for instance) for inspiration.
Good Luck,
Elmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 08:03 PM
02-23-2005 08:03 PM
Re: Moving of files using c programming..
> There is even more to it then that... The systemcall
> link only works on files on the same filesystem
Exactly. Using link() to copy from one filesystem to
another should return error and set errno to EXDEV.
I did not go into the details because Henry's exposure
to C is only couple of days old (see his other threads
on the topic).
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 08:10 PM
02-23-2005 08:10 PM
Re: Moving of files using c programming..
This system call will give you an array of all files that match a search pattern. You can then step through the array for each file and do what you want with it. If you are interested I could post an example of its use.
- Tags:
- glob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2005 12:36 PM
02-24-2005 12:36 PM
Re: Moving of files using c programming..
Thank for the input, I have downloaded the source code for mv in the linux.. kinda hard to digest for my level, do anyone has codes I can use that suit my needs?..
Sorry for the trouble..
Henry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2005 12:59 PM
02-24-2005 12:59 PM
Re: Moving of files using c programming..
copy of the file. Something like:
void copy (char *srcFilename, char *dstFileName)
{
FILE *fsrc, *fdst;
char c;
fsrc=fopen (srcFileName, "r");
/* Add usual error check */
fdst=fopen (dstFileName, "w");
/*Add usual error check */
for ( ; !feof(fsrc); )
fputc (fgetc (fsrc), fdst);
fclose (fsrc);
fclose (fdst);
}
Note that I have not tested the above code and
it does not do a lot of error checking, so you need
to do that before use.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2005 12:17 AM
02-25-2005 12:17 AM